aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/abituguru.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/abituguru.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/abituguru.c')
-rw-r--r--drivers/hwmon/abituguru.c3
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:
1287 for (i = 0; i < ARRAY_SIZE(abituguru_sysfs_attr); i++) 1287 for (i = 0; i < ARRAY_SIZE(abituguru_sysfs_attr); i++)
1288 device_remove_file(&pdev->dev, 1288 device_remove_file(&pdev->dev,
1289 &abituguru_sysfs_attr[i].dev_attr); 1289 &abituguru_sysfs_attr[i].dev_attr);
1290 platform_set_drvdata(pdev, NULL);
1290 kfree(data); 1291 kfree(data);
1291 return res; 1292 return res;
1292} 1293}
@@ -1296,13 +1297,13 @@ static int __devexit abituguru_remove(struct platform_device *pdev)
1296 int i; 1297 int i;
1297 struct abituguru_data *data = platform_get_drvdata(pdev); 1298 struct abituguru_data *data = platform_get_drvdata(pdev);
1298 1299
1299 platform_set_drvdata(pdev, NULL);
1300 hwmon_device_unregister(data->class_dev); 1300 hwmon_device_unregister(data->class_dev);
1301 for (i = 0; data->sysfs_attr[i].dev_attr.attr.name; i++) 1301 for (i = 0; data->sysfs_attr[i].dev_attr.attr.name; i++)
1302 device_remove_file(&pdev->dev, &data->sysfs_attr[i].dev_attr); 1302 device_remove_file(&pdev->dev, &data->sysfs_attr[i].dev_attr);
1303 for (i = 0; i < ARRAY_SIZE(abituguru_sysfs_attr); i++) 1303 for (i = 0; i < ARRAY_SIZE(abituguru_sysfs_attr); i++)
1304 device_remove_file(&pdev->dev, 1304 device_remove_file(&pdev->dev,
1305 &abituguru_sysfs_attr[i].dev_attr); 1305 &abituguru_sysfs_attr[i].dev_attr);
1306 platform_set_drvdata(pdev, NULL);
1306 kfree(data); 1307 kfree(data);
1307 1308
1308 return 0; 1309 return 0;