aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAxel Lin <axel.lin@gmail.com>2010-05-25 14:49:51 +0800
committerSamuel Ortiz <sameo@linux.intel.com>2010-08-12 11:27:17 +0200
commitd281b80c46da8bae806c4ef5682187f07e35389d (patch)
tree96ff99c6359cdf53cd2e0e6d862bc5fab9f2e159 /drivers
parent21f1fc38606b35bb12a4772367ef68128cd12c30 (diff)
downloadkernel_goldelico_gta04-d281b80c46da8bae806c4ef5682187f07e35389d.zip
kernel_goldelico_gta04-d281b80c46da8bae806c4ef5682187f07e35389d.tar.gz
kernel_goldelico_gta04-d281b80c46da8bae806c4ef5682187f07e35389d.tar.bz2
mfd: 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 <axel.lin@gmail.com> Acked-by: Linus Walleij <linus.walleij@stericsson.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mfd/ab3100-otp.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/drivers/mfd/ab3100-otp.c b/drivers/mfd/ab3100-otp.c
index 63d2b72..8440010 100644
--- a/drivers/mfd/ab3100-otp.c
+++ b/drivers/mfd/ab3100-otp.c
@@ -199,7 +199,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");
@@ -208,21 +208,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;
}