All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] drivers/elbc:Memory leak fix
@ 2015-05-20  9:24 Raghav Dogra
  2015-05-22 20:27 ` [U-Boot] " Scott Wood
  0 siblings, 1 reply; 5+ messages in thread
From: Raghav Dogra @ 2015-05-20  9:24 UTC (permalink / raw)
  To: u-boot

Freeing allocated memory to priv before returning
from the function

Signed-off-by: Raghav Dogra <raghav@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;
 	}
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [U-Boot] drivers/elbc:Memory leak fix
  2015-05-20  9:24 [U-Boot] [PATCH] drivers/elbc:Memory leak fix Raghav Dogra
@ 2015-05-22 20:27 ` Scott Wood
  2015-05-23  2:55   ` Kushwaha Prabhakar
  0 siblings, 1 reply; 5+ messages in thread
From: Scott Wood @ 2015-05-22 20:27 UTC (permalink / raw)
  To: u-boot

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@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.

-Scott

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] drivers/elbc:Memory leak fix
  2015-05-22 20:27 ` [U-Boot] " Scott Wood
@ 2015-05-23  2:55   ` Kushwaha Prabhakar
  2015-05-24  0:13     ` Scott Wood
  2015-05-24  3:31     ` Timur Tabi
  0 siblings, 2 replies; 5+ messages in thread
From: Kushwaha Prabhakar @ 2015-05-23  2:55 UTC (permalink / raw)
  To: u-boot

> -----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@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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] drivers/elbc:Memory leak fix
  2015-05-23  2:55   ` Kushwaha Prabhakar
@ 2015-05-24  0:13     ` Scott Wood
  2015-05-24  3:31     ` Timur Tabi
  1 sibling, 0 replies; 5+ messages in thread
From: Scott Wood @ 2015-05-24  0:13 UTC (permalink / raw)
  To: u-boot

On Fri, 2015-05-22 at 21:55 -0500, Kushwaha Prabhakar-B32579 wrote:
> > -----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@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* required.  Any pointer can be implicitly converted to a void
pointer.

>  It is not getting catch during GCC build. But during static analysis using Klockwork, this is shown as error. 

I don't care what Klockwork considers an error.  Klockwork does not
dictate the project's style guidelines.

> I will suggest to have this patch as it is. It is good practice to pass pointer in the desired format to called function. 

It is not good practice to cast unnecessarily.  Casts bypass the type
system and thus should be rare.

-Scott

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] drivers/elbc:Memory leak fix
  2015-05-23  2:55   ` Kushwaha Prabhakar
  2015-05-24  0:13     ` Scott Wood
@ 2015-05-24  3:31     ` Timur Tabi
  1 sibling, 0 replies; 5+ messages in thread
From: Timur Tabi @ 2015-05-24  3:31 UTC (permalink / raw)
  To: u-boot

On Fri, May 22, 2015 at 9:55 PM, Kushwaha Prabhakar
<prabhakar@freescale.com> wrote:
>
>  It is not getting catch during GCC build. But during static analysis using Klockwork, this is shown as error.

Then Klockwork is wrong.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-05-24  3:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-20  9:24 [U-Boot] [PATCH] drivers/elbc:Memory leak fix Raghav Dogra
2015-05-22 20:27 ` [U-Boot] " Scott Wood
2015-05-23  2:55   ` Kushwaha Prabhakar
2015-05-24  0:13     ` Scott Wood
2015-05-24  3:31     ` Timur Tabi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.