ab3100-otp: fix memory leak in ab3100_otp_probe
In current implementation, there is a memory leak if ab3100_otp_read fail. And in the case of ab3100_otp_init_debugfs fail, it does not properly remove sysfs entries.
This patch properly handle above failure cases.
Signed-off-by Axel Lin <[email protected]>
--- drivers/mfd/ab3100-otp.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-)
drivers/mfd/ab3100-otp.c +8 -8
@@ -202,7 +202,7 @@ static int __init ab3100_otp_probe(struct platform_device *pdev) err =ab3100_otp_read (otp);if (err) -return err; + goto err_otp_read;dev_info (&pdev->dev,"AB3100 OTP readout registered\n" );
@@ -211,21 +211,21 @@ static int __init ab3100_otp_probe(struct platform_device *pdev) err =device_create_file (&pdev->dev, &ab3100_otp_attrs[i]);if (err) - goto out_no_sysfs; + goto err_create_file; }/* debugfs entries */ err =ab3100_otp_init_debugfs (&pdev->dev, otp);if (err) - goto out_no_debugfs; + goto err_init_debugfs;return 0 ; -out_no_sysfs: -for (i =0 ; i <ARRAY_SIZE (ab3100_otp_attrs); i++) -device_remove_file (&pdev->dev, - &ab3100_otp_attrs[i]); -out_no_debugfs: +err_init_debugfs: +err_create_file: +while (--i >=0 ) +device_remove_file (&pdev->dev, &ab3100_otp_attrs[i]); +err_otp_read:kfree (otp);return err; }
Signature · 1 line
1.5.4.3
Linus WALLEIJ
Acked-by[Axel]
Quoted 7 lines
In current implementation, there is a memory leak if
ab3100_otp_readfail. And in the case ofab3100_otp_init_debugfsfail, it does not properly remove
sysfs entries.
This patch properly handle above failure cases.Signed-off-by Axel Lin <[email protected]>
Acked-by Linus Walleij <[email protected]>
Thanks for fixing this!
Yours,
Linus Walleij
Hi Axel,
Quoted 4 lines · Axel Lin
In current implementation, there is a memory leak if
ab3100_otp_readfail. And in the case ofab3100_otp_init_debugfsfail, it does not properly remove sysfs entries.
This patch properly handle above failure cases.
Patch applied, thanks a lot.
Cheers,
Samuel.
Quoted 52 lines
Signed-off-by Axel Lin <[email protected]>--- drivers/mfd/ab3100-otp.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-)drivers/mfd/ab3100-otp.c +8
-8@@ -202,7 +202,7 @@ static int __init ab3100_otp_probe(struct platform_device *pdev) err =ab3100_otp_read (otp);if (err) -return err; + goto err_otp_read;dev_info (&pdev->dev,"AB3100 OTP readout registered\n" );@@ -211,21 +211,21 @@ static int __init ab3100_otp_probe(struct platform_device *pdev) err =device_create_file (&pdev->dev, &ab3100_otp_attrs[i]);if (err) - goto out_no_sysfs; + goto err_create_file; }/* debugfs entries */ err =ab3100_otp_init_debugfs (&pdev->dev, otp);if (err) - goto out_no_debugfs; + goto err_init_debugfs;return 0 ; -out_no_sysfs: -for (i =0 ; i <ARRAY_SIZE (ab3100_otp_attrs); i++) -device_remove_file (&pdev->dev, - &ab3100_otp_attrs[i]); -out_no_debugfs: +err_init_debugfs: +err_create_file: +while (--i >=0 ) +device_remove_file (&pdev->dev, &ab3100_otp_attrs[i]); +err_otp_read:kfree (otp);return err; }Signature · 1 line
1.5.4.3
Signature · 2 lines
Intel Open Source Technology Centre http://oss.intel.com/