Skip to content

Commit

Permalink
[PATCH] hostap: Fix memory leak on PCI probe error path
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jouni Malinen authored and John W. Linville committed Mar 23, 2006
1 parent 4f7ecdf commit 9320199
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion drivers/net/wireless/hostap/hostap_pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down
9 changes: 5 additions & 4 deletions drivers/net/wireless/hostap/hostap_plx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -567,16 +567,17 @@ 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);

if (attr_mem)
iounmap(attr_mem);

pci_disable_device(pdev);
prism2_free_local_data(dev);

err_out_free:
kfree(hw_priv);

return -ENODEV;
}
Expand Down

0 comments on commit 9320199

Please sign in to comment.