[PATCH] gpu: drm: mediatek: mtk_drm_drv.c: Add of_node_put() before goto
CK Hu
ck.hu at mediatek.com
Mon Aug 19 01:30:31 UTC 2019
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 at 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;
> }
More information about the dri-devel
mailing list