[U-Boot] drivers/elbc:Memory leak fix
Kushwaha Prabhakar
prabhakar at freescale.com
Sat May 23 04:55:44 CEST 2015
> -----Original Message-----
> From: U-Boot [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Scott
> Wood
> Sent: Saturday, May 23, 2015 1:57 AM
> To: Dogra Raghav-B46184
> Cc: u-boot at lists.denx.de; Sun York-R58495
> Subject: Re: [U-Boot] drivers/elbc:Memory leak fix
>
> On Wed, May 20, 2015 at 02:54:58PM +0530, Raghav Dogra wrote:
> > Freeing allocated memory to priv before returning from the function
> >
> > Signed-off-by: Raghav Dogra <raghav at freescale.com>
> > ---
> > drivers/mtd/nand/fsl_elbc_nand.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/mtd/nand/fsl_elbc_nand.c
> > b/drivers/mtd/nand/fsl_elbc_nand.c
> > index e85832d..bbf1f39 100644
> > --- a/drivers/mtd/nand/fsl_elbc_nand.c
> > +++ b/drivers/mtd/nand/fsl_elbc_nand.c
> > @@ -679,6 +679,7 @@ static int fsl_elbc_chip_init(int devnum, u8 *addr)
> > if (priv->bank >= MAX_BANKS) {
> > printf("fsl_elbc_nand: address did not match any "
> > "chip selects\n");
> > + kfree((void *)priv);
> > return -ENODEV;
> > }
>
> Cast is unnecessary; I'll remove when applying.
>
It is required as kfree declaration need void pointer.
It is not getting catch during GCC build. But during static analysis using Klockwork, this is shown as error.
I will suggest to have this patch as it is. It is good practice to pass pointer in the desired format to called function.
--prabhakar
More information about the U-Boot
mailing list