Re: [PATCH] drm: rcar-du: Fix memory leak in rcar_du_vsps_init()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Biju,

Thank you for the patch.

On Wed, Nov 15, 2023 at 03:09:32PM +0000, Biju Das wrote:
> 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.

Good catch.

> Fixes: 3e81374e2014 ("drm: rcar-du: Support multiple sources from the same VSP")
> Signed-off-by: Biju Das <biju.das.jz@xxxxxxxxxxxxxx>
> ---
>  drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c
> index 70d8ad065bfa..5cd54ea33313 100644
> --- a/drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c
> +++ b/drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c
> @@ -747,8 +747,6 @@ static int rcar_du_vsps_init(struct rcar_du_device *rcdu)
>  			goto error;
>  	}
>  
> -	return 0;
> -
>  error:

If the code path is used in non-error cases as well, I'd prefer renaming
it to "done".

>  	for (i = 0; i < ARRAY_SIZE(vsps); ++i)
>  		of_node_put(vsps[i].np);

The next line is

	return ret;

When reached in the non-error case, ret is guaranteed to be
non-negative, as it has been assigned to the return value of
rcar_du_vsp_init(), with an

	if (ret < 0)

error check following it. While rcar_du_vsp_init() doesn't return a
positive value today, the code here would break in a way that may not be
immediately visible during review if this changed. I thus recommend
either assigning

	ret = 0;

in the success case, just before the "done" label, or changing the

	if (ret < 0)

test with

	if (ret)

after the call to rcar_du_vsp_init(). I think I have a preference for
the latter.

-- 
Regards,

Laurent Pinchart



[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux