Re: [2.6 patch] hostap_{pci,plx}.c: fix memory leaks

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

 



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 <[email protected]>
> 
> ---
> 
>  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: pgpb8hMky7vlC.pgp
Description: PGP signature


[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux