aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAmitkumar Karwar <akarwar@marvell.com>2013-11-14 22:10:41 -0500
committerJohn W. Linville <linville@tuxdriver.com>2013-11-15 14:29:32 -0500
commit3c59e328eb4ff23781bfa4cfc9f6f496003bf8b9 (patch)
tree11c69a91582c9eed44c5cb583bf65ab8dc052e57 /drivers
parent98a4635bba7050afdbdce428cc44a0471779ffc5 (diff)
mwifiex: fix memory leak issue for sdio and pcie cards
When driver is failed to load, card pointer doesn't get freed. We will free it in cleanup handler which is called in failure as well as unload path. Also, update drvdata in init/cleanup handlers instead of register/unregister handlers. Signed-off-by: Amitkumar Karwar <akarwar@marvell.com> Signed-off-by: Bing Zhao <bzhao@marvell.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/mwifiex/pcie.c2
-rw-r--r--drivers/net/wireless/mwifiex/sdio.c7
2 files changed, 5 insertions, 4 deletions
diff --git a/drivers/net/wireless/mwifiex/pcie.c b/drivers/net/wireless/mwifiex/pcie.c
index 33fa9432b241..03688aa14e8a 100644
--- a/drivers/net/wireless/mwifiex/pcie.c
+++ b/drivers/net/wireless/mwifiex/pcie.c
@@ -232,7 +232,6 @@ static void mwifiex_pcie_remove(struct pci_dev *pdev)
232 } 232 }
233 233
234 mwifiex_remove_card(card->adapter, &add_remove_card_sem); 234 mwifiex_remove_card(card->adapter, &add_remove_card_sem);
235 kfree(card);
236} 235}
237 236
238static void mwifiex_pcie_shutdown(struct pci_dev *pdev) 237static void mwifiex_pcie_shutdown(struct pci_dev *pdev)
@@ -2313,6 +2312,7 @@ static void mwifiex_pcie_cleanup(struct mwifiex_adapter *adapter)
2313 pci_release_region(pdev, 0); 2312 pci_release_region(pdev, 0);
2314 pci_set_drvdata(pdev, NULL); 2313 pci_set_drvdata(pdev, NULL);
2315 } 2314 }
2315 kfree(card);
2316} 2316}
2317 2317
2318/* 2318/*
diff --git a/drivers/net/wireless/mwifiex/sdio.c b/drivers/net/wireless/mwifiex/sdio.c
index 9bf8898743ab..b44a31523461 100644
--- a/drivers/net/wireless/mwifiex/sdio.c
+++ b/drivers/net/wireless/mwifiex/sdio.c
@@ -196,7 +196,6 @@ mwifiex_sdio_remove(struct sdio_func *func)
196 } 196 }
197 197
198 mwifiex_remove_card(card->adapter, &add_remove_card_sem); 198 mwifiex_remove_card(card->adapter, &add_remove_card_sem);
199 kfree(card);
200} 199}
201 200
202/* 201/*
@@ -1745,7 +1744,6 @@ mwifiex_unregister_dev(struct mwifiex_adapter *adapter)
1745 sdio_claim_host(card->func); 1744 sdio_claim_host(card->func);
1746 sdio_disable_func(card->func); 1745 sdio_disable_func(card->func);
1747 sdio_release_host(card->func); 1746 sdio_release_host(card->func);
1748 sdio_set_drvdata(card->func, NULL);
1749 } 1747 }
1750} 1748}
1751 1749
@@ -1773,7 +1771,6 @@ static int mwifiex_register_dev(struct mwifiex_adapter *adapter)
1773 return ret; 1771 return ret;
1774 } 1772 }
1775 1773
1776 sdio_set_drvdata(func, card);
1777 1774
1778 adapter->dev = &func->dev; 1775 adapter->dev = &func->dev;
1779 1776
@@ -1801,6 +1798,8 @@ static int mwifiex_init_sdio(struct mwifiex_adapter *adapter)
1801 int ret; 1798 int ret;
1802 u8 sdio_ireg; 1799 u8 sdio_ireg;
1803 1800
1801 sdio_set_drvdata(card->func, card);
1802
1804 /* 1803 /*
1805 * Read the HOST_INT_STATUS_REG for ACK the first interrupt got 1804 * Read the HOST_INT_STATUS_REG for ACK the first interrupt got
1806 * from the bootloader. If we don't do this we get a interrupt 1805 * from the bootloader. If we don't do this we get a interrupt
@@ -1883,6 +1882,8 @@ static void mwifiex_cleanup_sdio(struct mwifiex_adapter *adapter)
1883 kfree(card->mpa_rx.len_arr); 1882 kfree(card->mpa_rx.len_arr);
1884 kfree(card->mpa_tx.buf); 1883 kfree(card->mpa_tx.buf);
1885 kfree(card->mpa_rx.buf); 1884 kfree(card->mpa_rx.buf);
1885 sdio_set_drvdata(card->func, NULL);
1886 kfree(card);
1886} 1887}
1887 1888
1888/* 1889/*