diff options
author | Jean Delvare <khali@linux-fr.org> | 2007-06-12 13:57:19 +0200 |
---|---|---|
committer | Mark M. Hoffman <mhoffman@lightlink.com> | 2007-07-19 14:22:14 -0400 |
commit | 04a6217df28e3004ba4e76eb0a356a30f72c564f (patch) | |
tree | c2361be6f6a778dc769d77aa3e9ebfe0ebea366d /drivers/hwmon/abituguru.c | |
parent | ec5e1a4b8faa6a3522171a185a5c6ac9609e14b4 (diff) | |
download | blackbird-op-linux-04a6217df28e3004ba4e76eb0a356a30f72c564f.tar.gz blackbird-op-linux-04a6217df28e3004ba4e76eb0a356a30f72c564f.zip |
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/abituguru.c')
-rw-r--r-- | drivers/hwmon/abituguru.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/hwmon/abituguru.c b/drivers/hwmon/abituguru.c index bede4d990ea6..11a40da13535 100644 --- a/drivers/hwmon/abituguru.c +++ b/drivers/hwmon/abituguru.c @@ -1287,6 +1287,7 @@ abituguru_probe_error: for (i = 0; i < ARRAY_SIZE(abituguru_sysfs_attr); i++) device_remove_file(&pdev->dev, &abituguru_sysfs_attr[i].dev_attr); + platform_set_drvdata(pdev, NULL); kfree(data); return res; } @@ -1296,13 +1297,13 @@ static int __devexit abituguru_remove(struct platform_device *pdev) int i; struct abituguru_data *data = platform_get_drvdata(pdev); - platform_set_drvdata(pdev, NULL); hwmon_device_unregister(data->class_dev); for (i = 0; data->sysfs_attr[i].dev_attr.attr.name; i++) device_remove_file(&pdev->dev, &data->sysfs_attr[i].dev_attr); for (i = 0; i < ARRAY_SIZE(abituguru_sysfs_attr); i++) device_remove_file(&pdev->dev, &abituguru_sysfs_attr[i].dev_attr); + platform_set_drvdata(pdev, NULL); kfree(data); return 0; |