mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
pinctrl: ti: ti-iodelay: fix possible memory leak when pinctrl_enable() fails
[ Upstream commit 9b401f4a7170125365160c9af267a41ff6b39001 ]
This driver calls pinctrl_register_and_init() which is not
devm_ managed, it will leads memory leak if pinctrl_enable()
fails. Replace it with devm_pinctrl_register_and_init().
And add missing of_node_put() in the error path.
Fixes: 5038a66dad01 ("pinctrl: core: delete incorrect free in pinctrl_enable()")
Signed-off-by: Yang Yingliang <[email protected]>
Reviewed-by: Dan Carpenter <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Linus Walleij <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
This commit is contained in:
parent
932813248d
commit
b45432ce84
1 changed files with 6 additions and 5 deletions
|
|
@ -881,7 +881,7 @@ static int ti_iodelay_probe(struct platform_device *pdev)
|
|||
iod->desc.name = dev_name(dev);
|
||||
iod->desc.owner = THIS_MODULE;
|
||||
|
||||
ret = pinctrl_register_and_init(&iod->desc, dev, iod, &iod->pctl);
|
||||
ret = devm_pinctrl_register_and_init(dev, &iod->desc, iod, &iod->pctl);
|
||||
if (ret) {
|
||||
dev_err(dev, "Failed to register pinctrl\n");
|
||||
goto exit_out;
|
||||
|
|
@ -889,7 +889,11 @@ static int ti_iodelay_probe(struct platform_device *pdev)
|
|||
|
||||
platform_set_drvdata(pdev, iod);
|
||||
|
||||
return pinctrl_enable(iod->pctl);
|
||||
ret = pinctrl_enable(iod->pctl);
|
||||
if (ret)
|
||||
goto exit_out;
|
||||
|
||||
return 0;
|
||||
|
||||
exit_out:
|
||||
of_node_put(np);
|
||||
|
|
@ -906,9 +910,6 @@ static int ti_iodelay_remove(struct platform_device *pdev)
|
|||
{
|
||||
struct ti_iodelay_device *iod = platform_get_drvdata(pdev);
|
||||
|
||||
if (iod->pctl)
|
||||
pinctrl_unregister(iod->pctl);
|
||||
|
||||
ti_iodelay_pinconf_deinit_dev(iod);
|
||||
|
||||
/* Expect other allocations to be freed by devm */
|
||||
|
|
|
|||
Loading…
Reference in a new issue