aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/smsc47m1.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2007-06-12 07:57:19 -0400
committerMark M. Hoffman <mhoffman@lightlink.com>2007-07-19 14:22:14 -0400
commit04a6217df28e3004ba4e76eb0a356a30f72c564f (patch)
treec2361be6f6a778dc769d77aa3e9ebfe0ebea366d /drivers/hwmon/smsc47m1.c
parentec5e1a4b8faa6a3522171a185a5c6ac9609e14b4 (diff)
hwmon: Fix a potential race condition on unload
Fix a potential race condition when some hardware monitoring platform drivers are being unloaded. I believe that the driver data pointer shouldn't be cleared before all the sysfs files are removed, otherwise a sysfs callback might attempt to dereference a NULL pointer. I'm not sure exactly what the driver core protects drivers against, so let's play it safe. While we're here, clear the driver data pointer when probe fails, so as to not leave an invalid pointer behind us. Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
Diffstat (limited to 'drivers/hwmon/smsc47m1.c')
-rw-r--r--drivers/hwmon/smsc47m1.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c
index 9bac3c2d84f9..1de2f2be8708 100644
--- a/drivers/hwmon/smsc47m1.c
+++ b/drivers/hwmon/smsc47m1.c
@@ -597,6 +597,7 @@ static int __devinit smsc47m1_probe(struct platform_device *pdev)
597error_remove_files: 597error_remove_files:
598 sysfs_remove_group(&dev->kobj, &smsc47m1_group); 598 sysfs_remove_group(&dev->kobj, &smsc47m1_group);
599error_free: 599error_free:
600 platform_set_drvdata(pdev, NULL);
600 kfree(data); 601 kfree(data);
601error_release: 602error_release:
602 release_region(res->start, SMSC_EXTENT); 603 release_region(res->start, SMSC_EXTENT);
@@ -608,12 +609,12 @@ static int __devexit smsc47m1_remove(struct platform_device *pdev)
608 struct smsc47m1_data *data = platform_get_drvdata(pdev); 609 struct smsc47m1_data *data = platform_get_drvdata(pdev);
609 struct resource *res; 610 struct resource *res;
610 611
611 platform_set_drvdata(pdev, NULL);
612 hwmon_device_unregister(data->class_dev); 612 hwmon_device_unregister(data->class_dev);
613 sysfs_remove_group(&pdev->dev.kobj, &smsc47m1_group); 613 sysfs_remove_group(&pdev->dev.kobj, &smsc47m1_group);
614 614
615 res = platform_get_resource(pdev, IORESOURCE_IO, 0); 615 res = platform_get_resource(pdev, IORESOURCE_IO, 0);
616 release_region(res->start, SMSC_EXTENT); 616 release_region(res->start, SMSC_EXTENT);
617 platform_set_drvdata(pdev, NULL);
617 kfree(data); 618 kfree(data);
618 619
619 return 0; 620 return 0;