gpu: drm: mediatek: mtk_drm_drv.c: Add of_node_put() before goto
Subsystems (3)
PATCH 1/1 gpu: drm: mediatek: mtk_drm_drv.c: 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.
--- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_drm_drv.c +4 -1
@@ -524,12 +524,15 @@ static int mtk_drm_probe(struct platform_device *pdev) comp =devm_kzalloc (dev,sizeof (*comp),GFP_KERNEL );if (!comp) { ret = -ENOMEM ; +of_node_put (node); goto err_node; } ret =mtk_ddp_comp_init (dev, node, comp, comp_id,NULL ); -if (ret) +if (ret) { +of_node_put (node); goto err_node; + } private->ddp_comp[comp_id] = comp; }
Signature · 1 line
2.19.1
CK Hu
AppliedHi, Nishka:
Quoted 5 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.
Applied to mediatek-drm-fixes-5.3 [1], thanks.
[1]
https://github.com/ckhu-mediatek/linux.git-tags/tree/mediatek-drm-fixes-5.3
Regards,
CK
Quoted 17 lines
Signed-off-by Nishka Dasgupta <[email protected]>--- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/gpu/drm/mediatek/mtk_drm_drv.c +1
-0@@ -524,12 +524,15 @@ static int mtk_drm_probe(struct platform_device *pdev) comp =devm_kzalloc (dev,sizeof (*comp),GFP_KERNEL );if (!comp) { ret = -ENOMEM ; +of_node_put (node); goto err_node; }
drivers/gpu/drm/mediatek/mtk_drm_drv.c static int mtk_drm_probe(struct platform_device *pdev) · line 538
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_drm_drv.c +3
-1ret =mtk_ddp_comp_init (dev, node, comp, comp_id,NULL ); -if (ret) +if (ret) { +of_node_put (node); goto err_node; + } private->ddp_comp[comp_id] = comp; }
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel