mirror of https://gitee.com/openkylin/linux.git
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>
This commit is contained in:
parent
21f1fc3860
commit
d281b80c46
|
@ -199,7 +199,7 @@ static int __init ab3100_otp_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
err = ab3100_otp_read(otp);
|
err = ab3100_otp_read(otp);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
goto err_otp_read;
|
||||||
|
|
||||||
dev_info(&pdev->dev, "AB3100 OTP readout registered\n");
|
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,
|
err = device_create_file(&pdev->dev,
|
||||||
&ab3100_otp_attrs[i]);
|
&ab3100_otp_attrs[i]);
|
||||||
if (err)
|
if (err)
|
||||||
goto out_no_sysfs;
|
goto err_create_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* debugfs entries */
|
/* debugfs entries */
|
||||||
err = ab3100_otp_init_debugfs(&pdev->dev, otp);
|
err = ab3100_otp_init_debugfs(&pdev->dev, otp);
|
||||||
if (err)
|
if (err)
|
||||||
goto out_no_debugfs;
|
goto err_init_debugfs;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out_no_sysfs:
|
err_init_debugfs:
|
||||||
for (i = 0; i < ARRAY_SIZE(ab3100_otp_attrs); i++)
|
err_create_file:
|
||||||
device_remove_file(&pdev->dev,
|
while (--i >= 0)
|
||||||
&ab3100_otp_attrs[i]);
|
device_remove_file(&pdev->dev, &ab3100_otp_attrs[i]);
|
||||||
out_no_debugfs:
|
err_otp_read:
|
||||||
kfree(otp);
|
kfree(otp);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue