提交 93201999 编写于 作者: J Jouni Malinen 提交者: John W. Linville

[PATCH] hostap: Fix memory leak on PCI probe error path

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: NJouni Malinen <jkmaline@cc.hut.fi>
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
上级 4f7ecdf0
...@@ -307,7 +307,7 @@ static int prism2_pci_probe(struct pci_dev *pdev, ...@@ -307,7 +307,7 @@ static int prism2_pci_probe(struct pci_dev *pdev,
memset(hw_priv, 0, sizeof(*hw_priv)); memset(hw_priv, 0, sizeof(*hw_priv));
if (pci_enable_device(pdev)) if (pci_enable_device(pdev))
return -EIO; goto err_out_free;
phymem = pci_resource_start(pdev, 0); phymem = pci_resource_start(pdev, 0);
...@@ -368,6 +368,8 @@ static int prism2_pci_probe(struct pci_dev *pdev, ...@@ -368,6 +368,8 @@ static int prism2_pci_probe(struct pci_dev *pdev,
err_out_disable: err_out_disable:
pci_disable_device(pdev); pci_disable_device(pdev);
prism2_free_local_data(dev); prism2_free_local_data(dev);
err_out_free:
kfree(hw_priv); kfree(hw_priv);
return -ENODEV; return -ENODEV;
......
...@@ -452,7 +452,7 @@ static int prism2_plx_probe(struct pci_dev *pdev, ...@@ -452,7 +452,7 @@ static int prism2_plx_probe(struct pci_dev *pdev,
memset(hw_priv, 0, sizeof(*hw_priv)); memset(hw_priv, 0, sizeof(*hw_priv));
if (pci_enable_device(pdev)) if (pci_enable_device(pdev))
return -EIO; goto err_out_free;
/* National Datacomm NCP130 based on TMD7160, not PLX9052. */ /* National Datacomm NCP130 based on TMD7160, not PLX9052. */
tmd7160 = (pdev->vendor == 0x15e8) && (pdev->device == 0x0131); tmd7160 = (pdev->vendor == 0x15e8) && (pdev->device == 0x0131);
...@@ -567,9 +567,6 @@ static int prism2_plx_probe(struct pci_dev *pdev, ...@@ -567,9 +567,6 @@ static int prism2_plx_probe(struct pci_dev *pdev,
return hostap_hw_ready(dev); return hostap_hw_ready(dev);
fail: fail:
prism2_free_local_data(dev);
kfree(hw_priv);
if (irq_registered && dev) if (irq_registered && dev)
free_irq(dev->irq, dev); free_irq(dev->irq, dev);
...@@ -577,6 +574,10 @@ static int prism2_plx_probe(struct pci_dev *pdev, ...@@ -577,6 +574,10 @@ static int prism2_plx_probe(struct pci_dev *pdev,
iounmap(attr_mem); iounmap(attr_mem);
pci_disable_device(pdev); pci_disable_device(pdev);
prism2_free_local_data(dev);
err_out_free:
kfree(hw_priv);
return -ENODEV; return -ENODEV;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册