netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [2.6 patch] hostap_{pci,plx}.c: fix memory leaks
@ 2006-03-13 22:28 Adrian Bunk
  2006-03-14  2:25 ` Herbert Xu
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Adrian Bunk @ 2006-03-13 22:28 UTC (permalink / raw)
  To: jkmaline; +Cc: hostap, netdev, linux-kernel

This patch fixes two memotry leaks spotted by the Coverity checker.


Signed-off-by: Adrian Bunk <bunk@stusta.de>

---

 drivers/net/wireless/hostap/hostap_pci.c |    6 +++---
 drivers/net/wireless/hostap/hostap_plx.c |    6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

--- linux-2.6.16-rc6-mm1-full/drivers/net/wireless/hostap/hostap_pci.c.old	2006-03-13 22:34:30.000000000 +0100
+++ linux-2.6.16-rc6-mm1-full/drivers/net/wireless/hostap/hostap_pci.c	2006-03-13 22:37:57.000000000 +0100
@@ -301,14 +301,14 @@ static int prism2_pci_probe(struct pci_d
 	struct hostap_interface *iface;
 	struct hostap_pci_priv *hw_priv;
 
+	if (pci_enable_device(pdev))
+		return -EIO;
+
 	hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL);
 	if (hw_priv == NULL)
 		return -ENOMEM;
 	memset(hw_priv, 0, sizeof(*hw_priv));
 
-	if (pci_enable_device(pdev))
-		return -EIO;
-
 	phymem = pci_resource_start(pdev, 0);
 
 	if (!request_mem_region(phymem, pci_resource_len(pdev, 0), "Prism2")) {
--- linux-2.6.16-rc6-mm1-full/drivers/net/wireless/hostap/hostap_plx.c.old	2006-03-13 22:39:40.000000000 +0100
+++ linux-2.6.16-rc6-mm1-full/drivers/net/wireless/hostap/hostap_plx.c	2006-03-13 22:40:09.000000000 +0100
@@ -446,14 +446,14 @@ static int prism2_plx_probe(struct pci_d
 	int tmd7160;
 	struct hostap_plx_priv *hw_priv;
 
+	if (pci_enable_device(pdev))
+		return -EIO;
+
 	hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL);
 	if (hw_priv == NULL)
 		return -ENOMEM;
 	memset(hw_priv, 0, sizeof(*hw_priv));
 
-	if (pci_enable_device(pdev))
-		return -EIO;
-
 	/* National Datacomm NCP130 based on TMD7160, not PLX9052. */
 	tmd7160 = (pdev->vendor == 0x15e8) && (pdev->device == 0x0131);
 

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

* Re: [2.6 patch] hostap_{pci,plx}.c: fix memory leaks
  2006-03-13 22:28 [2.6 patch] hostap_{pci,plx}.c: fix memory leaks Adrian Bunk
@ 2006-03-14  2:25 ` Herbert Xu
  2006-03-14 14:30 ` Michael Buesch
  2006-03-15  3:16 ` Jouni Malinen
  2 siblings, 0 replies; 5+ messages in thread
From: Herbert Xu @ 2006-03-14  2:25 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: jkmaline, hostap, netdev, linux-kernel

Adrian Bunk <bunk@stusta.de> wrote:
> 
> +       if (pci_enable_device(pdev))
> +               return -EIO;
> +
>        hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL);
>        if (hw_priv == NULL)
>                return -ENOMEM;
>        memset(hw_priv, 0, sizeof(*hw_priv));
> 
> -       if (pci_enable_device(pdev))
> -               return -EIO;
> -

You've just turned it into a leak of a different kind.

Why not jump to the error exit instead?

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

* Re: [2.6 patch] hostap_{pci,plx}.c: fix memory leaks
  2006-03-13 22:28 [2.6 patch] hostap_{pci,plx}.c: fix memory leaks Adrian Bunk
  2006-03-14  2:25 ` Herbert Xu
@ 2006-03-14 14:30 ` Michael Buesch
  2006-03-15  3:16 ` Jouni Malinen
  2 siblings, 0 replies; 5+ messages in thread
From: Michael Buesch @ 2006-03-14 14:30 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: jkmaline, hostap, netdev, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2008 bytes --]

On Monday 13 March 2006 23:28, you wrote:
> This patch fixes two memotry leaks spotted by the Coverity checker.
> 
> 
> Signed-off-by: Adrian Bunk <bunk@stusta.de>
> 
> ---
> 
>  drivers/net/wireless/hostap/hostap_pci.c |    6 +++---
>  drivers/net/wireless/hostap/hostap_plx.c |    6 +++---
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> --- linux-2.6.16-rc6-mm1-full/drivers/net/wireless/hostap/hostap_pci.c.old	2006-03-13 22:34:30.000000000 +0100
> +++ linux-2.6.16-rc6-mm1-full/drivers/net/wireless/hostap/hostap_pci.c	2006-03-13 22:37:57.000000000 +0100
> @@ -301,14 +301,14 @@ static int prism2_pci_probe(struct pci_d
>  	struct hostap_interface *iface;
>  	struct hostap_pci_priv *hw_priv;
>  
> +	if (pci_enable_device(pdev))
> +		return -EIO;
> +
>  	hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL);
>  	if (hw_priv == NULL)

+               pci_disable_device(pdev);

>  		return -ENOMEM;
>  	memset(hw_priv, 0, sizeof(*hw_priv));
>  
> -	if (pci_enable_device(pdev))
> -		return -EIO;
> -
>  	phymem = pci_resource_start(pdev, 0);
>  
>  	if (!request_mem_region(phymem, pci_resource_len(pdev, 0), "Prism2")) {
> --- linux-2.6.16-rc6-mm1-full/drivers/net/wireless/hostap/hostap_plx.c.old	2006-03-13 22:39:40.000000000 +0100
> +++ linux-2.6.16-rc6-mm1-full/drivers/net/wireless/hostap/hostap_plx.c	2006-03-13 22:40:09.000000000 +0100
> @@ -446,14 +446,14 @@ static int prism2_plx_probe(struct pci_d
>  	int tmd7160;
>  	struct hostap_plx_priv *hw_priv;
>  
> +	if (pci_enable_device(pdev))
> +		return -EIO;
> +
>  	hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL);
>  	if (hw_priv == NULL)

Seems like pci_disable_device should be done here, too.

>  		return -ENOMEM;
>  	memset(hw_priv, 0, sizeof(*hw_priv));
>  
> -	if (pci_enable_device(pdev))
> -		return -EIO;
> -
>  	/* National Datacomm NCP130 based on TMD7160, not PLX9052. */
>  	tmd7160 = (pdev->vendor == 0x15e8) && (pdev->device == 0x0131);

-- 
Greetings Michael.

[-- Attachment #2: Type: application/pgp-signature, Size: 191 bytes --]

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

* Re: [2.6 patch] hostap_{pci,plx}.c: fix memory leaks
  2006-03-13 22:28 [2.6 patch] hostap_{pci,plx}.c: fix memory leaks Adrian Bunk
  2006-03-14  2:25 ` Herbert Xu
  2006-03-14 14:30 ` Michael Buesch
@ 2006-03-15  3:16 ` Jouni Malinen
  2006-03-15 16:14   ` Adrian Bunk
  2 siblings, 1 reply; 5+ messages in thread
From: Jouni Malinen @ 2006-03-15  3:16 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: netdev, hostap, linux-kernel

On Mon, Mar 13, 2006 at 11:28:41PM +0100, Adrian Bunk wrote:
> This patch fixes two memotry leaks spotted by the Coverity checker.

Thanks. I'll make a bit different patch to resolve this and related PCI
"leaks" in one change. I'm going through the Coverity reports for Host
AP driver, so I'll include other fixes in a patch set, too.

-- 
Jouni Malinen                                            PGP id EFC895FA

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

* Re: [2.6 patch] hostap_{pci,plx}.c: fix memory leaks
  2006-03-15  3:16 ` Jouni Malinen
@ 2006-03-15 16:14   ` Adrian Bunk
  0 siblings, 0 replies; 5+ messages in thread
From: Adrian Bunk @ 2006-03-15 16:14 UTC (permalink / raw)
  To: hostap, netdev, linux-kernel; +Cc: Herbert Xu

On Tue, Mar 14, 2006 at 07:16:25PM -0800, Jouni Malinen wrote:
> On Mon, Mar 13, 2006 at 11:28:41PM +0100, Adrian Bunk wrote:
> > This patch fixes two memotry leaks spotted by the Coverity checker.
> 
> Thanks. I'll make a bit different patch to resolve this and related PCI
> "leaks" in one change. I'm going through the Coverity reports for Host
> AP driver, so I'll include other fixes in a patch set, too.

Thanks (I assume you've seem Herbert's comment why my patch was wrong).

> Jouni Malinen                                            PGP id EFC895FA

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

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

end of thread, other threads:[~2006-03-15 16:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-13 22:28 [2.6 patch] hostap_{pci,plx}.c: fix memory leaks Adrian Bunk
2006-03-14  2:25 ` Herbert Xu
2006-03-14 14:30 ` Michael Buesch
2006-03-15  3:16 ` Jouni Malinen
2006-03-15 16:14   ` Adrian Bunk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).