From: Guenter Roeck Date: Mon, 12 Mar 2012 15:33:10 +0000 (-0700) Subject: hwmon: (w83627ehf) Fix memory leak in probe function X-Git-Tag: firefly_0821_release~7541^2~1561 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=90b7d65c8cba8830ede8307a21a76c8757eefa3a;p=firefly-linux-kernel-4.4.55.git hwmon: (w83627ehf) Fix memory leak in probe function commit 32260d94408c553dca4ce54104edf79941a27536 upstream. 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 Acked-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/hwmon/w83627ehf.c b/drivers/hwmon/w83627ehf.c index 685399b5334c..e51b582bbc58 100644 --- a/drivers/hwmon/w83627ehf.c +++ b/drivers/hwmon/w83627ehf.c @@ -1823,7 +1823,8 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev) goto exit; } - data = kzalloc(sizeof(struct w83627ehf_data), GFP_KERNEL); + data = devm_kzalloc(&pdev->dev, sizeof(struct w83627ehf_data), + GFP_KERNEL); if (!data) { err = -ENOMEM; goto exit_release; @@ -2319,9 +2320,8 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev) exit_remove: w83627ehf_device_remove_files(dev); - kfree(data); - platform_set_drvdata(pdev, NULL); exit_release: + platform_set_drvdata(pdev, NULL); release_region(res->start, IOREGION_LENGTH); exit: return err; @@ -2335,7 +2335,6 @@ static int __devexit w83627ehf_remove(struct platform_device *pdev) w83627ehf_device_remove_files(&pdev->dev); release_region(data->addr, IOREGION_LENGTH); platform_set_drvdata(pdev, NULL); - kfree(data); return 0; }