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>
This commit is contained in:
committed by
Mark M. Hoffman
parent
ec5e1a4b8f
commit
04a6217df2
@ -484,7 +484,6 @@ static int __devexit pc87427_remove(struct platform_device *pdev)
|
||||
struct resource *res;
|
||||
int i;
|
||||
|
||||
platform_set_drvdata(pdev, NULL);
|
||||
hwmon_device_unregister(data->class_dev);
|
||||
device_remove_file(&pdev->dev, &dev_attr_name);
|
||||
for (i = 0; i < 8; i++) {
|
||||
@ -492,6 +491,7 @@ static int __devexit pc87427_remove(struct platform_device *pdev)
|
||||
continue;
|
||||
sysfs_remove_group(&pdev->dev.kobj, &pc87427_group_fan[i]);
|
||||
}
|
||||
platform_set_drvdata(pdev, NULL);
|
||||
kfree(data);
|
||||
|
||||
res = platform_get_resource(pdev, IORESOURCE_IO, 0);
|
||||
|
Reference in New Issue
Block a user