summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Gardner <tim.gardner@canonical.com>2012-02-02 13:48:06 -0700
committerJohn W. Linville <linville@tuxdriver.com>2012-02-06 14:55:52 -0500
commit3d86b93064c7f18378a2008bab9608ca7d11bdbb (patch)
treedad5a3e5e53a7b87397472599d00d0fc0dae6137
parent885bd8eca6ac172e299750d99bd5c9fddbed89b9 (diff)
rtlwifi: Fix PCI probe error path orphaned memory
Memory allocated by ieee80211_alloc_hw() will get orphaned if any subsequent initializations fail. Also don't pci_set_drvdata(pdev, NULL) until just before disabling the PCI device. Functions called by rtl_deinit_core(hw) may eventually need the context (when its actually implemented). Cc: Larry Finger <Larry.Finger@lwfinger.net> Cc: Chaoming Li <chaoming_li@realsil.com.cn> Cc: John W. Linville <linville@tuxdriver.com> Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Tim Gardner <tim.gardner@canonical.com> Acked-by: Larry Finger <Larry.Finger@lwfinger.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/rtlwifi/pci.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
index 9a0190944de5..c5f6a322feb2 100644
--- a/drivers/net/wireless/rtlwifi/pci.c
+++ b/drivers/net/wireless/rtlwifi/pci.c
@@ -1758,8 +1758,8 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev,
if (pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) {
RT_ASSERT(false,
"Unable to obtain 32bit DMA for consistent allocations\n");
- pci_disable_device(pdev);
- return -ENOMEM;
+ err = -ENOMEM;
+ goto fail1;
}
}
@@ -1801,7 +1801,7 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev,
err = pci_request_regions(pdev, KBUILD_MODNAME);
if (err) {
RT_ASSERT(false, "Can't obtain PCI resources\n");
- goto fail2;
+ goto fail1;
}
pmem_start = pci_resource_start(pdev, rtlpriv->cfg->bar_id);
@@ -1814,6 +1814,7 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev,
rtlpriv->cfg->bar_id, pmem_len);
if (rtlpriv->io.pci_mem_start == 0) {
RT_ASSERT(false, "Can't map PCI mem\n");
+ err = -ENOMEM;
goto fail2;
}
@@ -1830,8 +1831,10 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev,
pci_write_config_byte(pdev, 0x04, 0x07);
/* find adapter */
- if (!_rtl_pci_find_adapter(pdev, hw))
+ if (!_rtl_pci_find_adapter(pdev, hw)) {
+ err = -ENODEV;
goto fail3;
+ }
/* Init IO handler */
_rtl_pci_io_handler_init(&pdev->dev, hw);
@@ -1841,6 +1844,7 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev,
if (rtlpriv->cfg->ops->init_sw_vars(hw)) {
RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Can't init_sw_vars\n");
+ err = -ENODEV;
goto fail3;
}
@@ -1885,7 +1889,6 @@ int __devinit rtl_pci_probe(struct pci_dev *pdev,
return 0;
fail3:
- pci_set_drvdata(pdev, NULL);
rtl_deinit_core(hw);
_rtl_pci_io_handler_release(hw);
@@ -1897,10 +1900,12 @@ fail2:
complete(&rtlpriv->firmware_loading_complete);
fail1:
-
+ if (hw)
+ ieee80211_free_hw(hw);
+ pci_set_drvdata(pdev, NULL);
pci_disable_device(pdev);
- return -ENODEV;
+ return err;
}
EXPORT_SYMBOL(rtl_pci_probe);