media: platform: mtk-mdp: mtk_mdp_core: Add of_node_put() before goto
Subsystems (2)
PATCH 1/1 media: platform: mtk-mdp: mtk_mdp_core: Add of_node_put() before goto
Each iteration of for_each_child_of_node puts the previous node, but in the case of a goto from the middle of the loop, there is no put, thus causing a memory leak. Hence add an of_node_put before the goto in two places.
Issue found with Coccinelle.
Signed-off-by Nishka Dasgupta <[email protected]>
--- drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/media/platform/mtk-mdp/mtk_mdp_core.c +4 -1
@@ -145,13 +145,16 @@ static int mtk_mdp_probe(struct platform_device *pdev) comp =devm_kzalloc (dev,sizeof (*comp),GFP_KERNEL );if (!comp) { ret = -ENOMEM ; +of_node_put (node); goto err_comp; } mdp->comp[comp_id] = comp; ret =mtk_mdp_comp_init (dev, node, comp, comp_id); -if (ret) +if (ret) { +of_node_put (node); goto err_comp; + } } mdp->job_wq =create_singlethread_workqueue (MTK_MDP_MODULE_NAME );
Signature · 1 line
2.19.1
Quoted 23 lines · Nishka Dasgupta
Each iteration of
for_each_child_of_nodeputs the previous node, but in the case of a goto from the middle of the loop, there is no put, thus causing a memory leak. Hence add anof_node_putbefore the goto in two places.
Issue found with Coccinelle.Signed-off-by Nishka Dasgupta <[email protected]>--- drivers/media/platform/mtk-mdp/mtk_mdp_core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/media/platform/mtk-mdp/mtk_mdp_core.c +1
-0@@ -145,13 +145,16 @@ static int mtk_mdp_probe(struct platform_device *pdev) comp =devm_kzalloc (dev,sizeof (*comp),GFP_KERNEL );if (!comp) { ret = -ENOMEM ; +of_node_put (node); goto err_comp; } mdp->comp[comp_id] = comp;
drivers/media/platform/mtk-mdp/mtk_mdp_core.c static int mtk_mdp_probe(struct platform_device *pdev) · line 160
Quoted 10 lines
drivers/media/platform/mtk-mdp/mtk_mdp_core.c +3
-1ret =mtk_mdp_comp_init (dev, node, comp, comp_id); -if (ret) +if (ret) { +of_node_put (node); goto err_comp; + } } mdp->job_wq =create_singlethread_workqueue (MTK_MDP_MODULE_NAME );
Thanks Nishka for fixing the bug.
Acked-by Houlong Wei <[email protected]>