OSDN Git Service

media: platform: mtk-mdp: mtk_mdp_core: Add of_node_put() before goto
authorNishka Dasgupta <nishkadg.linux@gmail.com>
Tue, 9 Jul 2019 17:24:54 +0000 (14:24 -0300)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Tue, 13 Aug 2019 14:49:46 +0000 (11:49 -0300)
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 <nishkadg.linux@gmail.com>
Acked-by: Houlong Wei <houlong.wei@mediatek.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/platform/mtk-mdp/mtk_mdp_core.c

index 5d44f2e..c1e29a4 100644 (file)
@@ -147,13 +147,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);