* [PATCH] gpu: drm: mediatek: mtk_drm_drv.c: Add of_node_put() before goto
@ 2019-07-06 13:30 Nishka Dasgupta
2019-08-19 1:30 ` CK Hu
0 siblings, 1 reply; 2+ messages in thread
From: Nishka Dasgupta @ 2019-07-06 13:30 UTC (permalink / raw)
To: ck.hu, p.zabel, matthias.bgg, airlie, daniel, dri-devel,
linux-arm-kernel, linux-mediatek
Cc: Nishka Dasgupta
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>
---
drivers/gpu/drm/mediatek/mtk_drm_drv.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
index 95fdbd0fbcac..2dffbc8c6d73 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -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;
}
--
2.19.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] gpu: drm: mediatek: mtk_drm_drv.c: Add of_node_put() before goto
2019-07-06 13:30 [PATCH] gpu: drm: mediatek: mtk_drm_drv.c: Add of_node_put() before goto Nishka Dasgupta
@ 2019-08-19 1:30 ` CK Hu
0 siblings, 0 replies; 2+ messages in thread
From: CK Hu @ 2019-08-19 1:30 UTC (permalink / raw)
To: Nishka Dasgupta
Cc: p.zabel, airlie, dri-devel, linux-mediatek, daniel, matthias.bgg,
linux-arm-kernel
Hi, Nishka:
On Sat, 2019-07-06 at 19:00 +0530, Nishka Dasgupta wrote:
> 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.
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
>
> Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
> ---
> drivers/gpu/drm/mediatek/mtk_drm_drv.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index 95fdbd0fbcac..2dffbc8c6d73 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -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;
> }
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-08-19 1:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-06 13:30 [PATCH] gpu: drm: mediatek: mtk_drm_drv.c: Add of_node_put() before goto Nishka Dasgupta
2019-08-19 1:30 ` CK Hu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).