Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm: rcar-du: Fix memory leak in rcar_du_vsps_init()

The rcar_du_vsps_init() doesn't free the np allocated by
of_parse_phandle_with_fixed_args() for the non-error case.

Fix memory leak for the non-error case.

While at it, replace the label 'error'->'done' as it applies to non-error
case as well and update the error check condition for rcar_du_vsp_init()
to avoid breakage in future, if it returns positive value.

Fixes: 3e81374e2014 ("drm: rcar-du: Support multiple sources from the same VSP")
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Link: https://lore.kernel.org/r/20231116122424.80136-1-biju.das.jz@bp.renesas.com
Signed-off-by: Tomi Valkeinen <tomi.valkeinen+renesas@ideasonboard.com>

authored by

Biju Das and committed by
Tomi Valkeinen
91e3bf09 4f1a965d

+4 -6
+4 -6
drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c
··· 705 705 ret = of_parse_phandle_with_fixed_args(np, vsps_prop_name, 706 706 cells, i, &args); 707 707 if (ret < 0) 708 - goto error; 708 + goto done; 709 709 710 710 /* 711 711 * Add the VSP to the list or update the corresponding existing ··· 743 743 vsp->dev = rcdu; 744 744 745 745 ret = rcar_du_vsp_init(vsp, vsps[i].np, vsps[i].crtcs_mask); 746 - if (ret < 0) 747 - goto error; 746 + if (ret) 747 + goto done; 748 748 } 749 749 750 - return 0; 751 - 752 - error: 750 + done: 753 751 for (i = 0; i < ARRAY_SIZE(vsps); ++i) 754 752 of_node_put(vsps[i].np); 755 753