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 Laurent,

Thanks for the feedback.

> -----Original Message-----
> From: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx>
> Sent: Thursday, November 16, 2023 1:25 AM
> Subject: Re: [PATCH] drm: rcar-du: Fix memory leak in rcar_du_vsps_init()
> 
> 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.

Agreed, will send v2 for changing error->done and if (ret) condition.

Cheers,
Biju




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux