switch: avoid memory access after free
Krishna Reddy [Fri, 30 Aug 2013 15:38:41 +0000 (08:38 -0700)]
driver data has to be set before destory of device to
avoid accessing memory after free.

Change-Id: Id06a9239a26958917363c45721dc0bee1aba1ced
Signed-off-by: Krishna Reddy <vdumpa@nvidia.com>
Reviewed-on: http://git-master/r/268587
Reviewed-by: Alex Waterman <alexw@nvidia.com>
GVS: Gerrit_Virtual_Submit

drivers/switch/switch_class.c

index e373b62..a008699 100644 (file)
@@ -151,8 +151,8 @@ void switch_dev_unregister(struct switch_dev *sdev)
 {
        device_remove_file(sdev->dev, &dev_attr_name);
        device_remove_file(sdev->dev, &dev_attr_state);
-       device_destroy(switch_class, MKDEV(0, sdev->index));
        dev_set_drvdata(sdev->dev, NULL);
+       device_destroy(switch_class, MKDEV(0, sdev->index));
 }
 EXPORT_SYMBOL_GPL(switch_dev_unregister);