hwmon: (w83627ehf) Fix memory leak in probe function

The driver probe function leaked memory if creating the cpu0_vid attribute file
failed. Fix by converting the driver to use devm_kzalloc.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Cc: stable@vger.kernel.org # 2.6.32+
Acked-by: Jean Delvare <khali@linux-fr.org>
This commit is contained in:
Guenter Roeck 2012-03-12 08:33:10 -07:00 коммит произвёл Guenter Roeck
Родитель 33fa9b6204
Коммит 32260d9440
1 изменённых файлов: 3 добавлений и 4 удалений

Просмотреть файл

@ -2004,7 +2004,8 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
goto exit; goto exit;
} }
data = kzalloc(sizeof(struct w83627ehf_data), GFP_KERNEL); data = devm_kzalloc(&pdev->dev, sizeof(struct w83627ehf_data),
GFP_KERNEL);
if (!data) { if (!data) {
err = -ENOMEM; err = -ENOMEM;
goto exit_release; goto exit_release;
@ -2493,9 +2494,8 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
exit_remove: exit_remove:
w83627ehf_device_remove_files(dev); w83627ehf_device_remove_files(dev);
kfree(data);
platform_set_drvdata(pdev, NULL);
exit_release: exit_release:
platform_set_drvdata(pdev, NULL);
release_region(res->start, IOREGION_LENGTH); release_region(res->start, IOREGION_LENGTH);
exit: exit:
return err; return err;
@ -2509,7 +2509,6 @@ static int __devexit w83627ehf_remove(struct platform_device *pdev)
w83627ehf_device_remove_files(&pdev->dev); w83627ehf_device_remove_files(&pdev->dev);
release_region(data->addr, IOREGION_LENGTH); release_region(data->addr, IOREGION_LENGTH);
platform_set_drvdata(pdev, NULL); platform_set_drvdata(pdev, NULL);
kfree(data);
return 0; return 0;
} }