]> err.no Git - linux-2.6/commitdiff
[PATCH] hostap: Fix memory leak on PCI probe error path
authorJouni Malinen <jkmaline@cc.hut.fi>
Mon, 20 Mar 2006 03:21:49 +0000 (19:21 -0800)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 23 Mar 2006 21:16:58 +0000 (16:16 -0500)
The Coverity checker (CID: 659, 660) spotted this resource leak on
PCI probe error path. Free private data structure if pci_enable_device()
fails.

Signed-off-by: Jouni Malinen <jkmaline@cc.hut.fi>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/hostap/hostap_pci.c
drivers/net/wireless/hostap/hostap_plx.c

index 2e85bdced2dd7fd74d721ef1f147065adecf8829..194f07097581dcdb538b05b077d18db5eeb76bc7 100644 (file)
@@ -307,7 +307,7 @@ static int prism2_pci_probe(struct pci_dev *pdev,
        memset(hw_priv, 0, sizeof(*hw_priv));
 
        if (pci_enable_device(pdev))
-               return -EIO;
+               goto err_out_free;
 
        phymem = pci_resource_start(pdev, 0);
 
@@ -368,6 +368,8 @@ static int prism2_pci_probe(struct pci_dev *pdev,
  err_out_disable:
        pci_disable_device(pdev);
        prism2_free_local_data(dev);
+
+ err_out_free:
        kfree(hw_priv);
 
        return -ENODEV;
index e258517ac85db50af3b774720441254eb1836e36..edaaa943eb8f54c026c436e6b62a19a9e3ee3ee8 100644 (file)
@@ -452,7 +452,7 @@ static int prism2_plx_probe(struct pci_dev *pdev,
        memset(hw_priv, 0, sizeof(*hw_priv));
 
        if (pci_enable_device(pdev))
-               return -EIO;
+               goto err_out_free;
 
        /* National Datacomm NCP130 based on TMD7160, not PLX9052. */
        tmd7160 = (pdev->vendor == 0x15e8) && (pdev->device == 0x0131);
@@ -567,9 +567,6 @@ static int prism2_plx_probe(struct pci_dev *pdev,
        return hostap_hw_ready(dev);
 
  fail:
-       prism2_free_local_data(dev);
-       kfree(hw_priv);
-
        if (irq_registered && dev)
                free_irq(dev->irq, dev);
 
@@ -577,6 +574,10 @@ static int prism2_plx_probe(struct pci_dev *pdev,
                iounmap(attr_mem);
 
        pci_disable_device(pdev);
+       prism2_free_local_data(dev);
+
+ err_out_free:
+       kfree(hw_priv);
 
        return -ENODEV;
 }