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

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

drivers/staging/android/timed_output.c

index ec9e2ae..b8dde89 100644 (file)
@@ -103,8 +103,8 @@ void timed_output_dev_unregister(struct timed_output_dev *tdev)
 {
        tdev->enable(tdev, 0);
        device_remove_file(tdev->dev, &dev_attr_enable);
-       device_destroy(timed_output_class, MKDEV(0, tdev->index));
        dev_set_drvdata(tdev->dev, NULL);
+       device_destroy(timed_output_class, MKDEV(0, tdev->index));
 }
 EXPORT_SYMBOL_GPL(timed_output_dev_unregister);