Commit 3c59e328 authored by Amitkumar Karwar's avatar Amitkumar Karwar Committed by John W. Linville

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: default avatarAmitkumar Karwar <akarwar@marvell.com>
Signed-off-by: default avatarBing Zhao <bzhao@marvell.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 98a4635b
...@@ -232,7 +232,6 @@ static void mwifiex_pcie_remove(struct pci_dev *pdev) ...@@ -232,7 +232,6 @@ static void mwifiex_pcie_remove(struct pci_dev *pdev)
} }
mwifiex_remove_card(card->adapter, &add_remove_card_sem); mwifiex_remove_card(card->adapter, &add_remove_card_sem);
kfree(card);
} }
static void mwifiex_pcie_shutdown(struct pci_dev *pdev) static void mwifiex_pcie_shutdown(struct pci_dev *pdev)
...@@ -2313,6 +2312,7 @@ static void mwifiex_pcie_cleanup(struct mwifiex_adapter *adapter) ...@@ -2313,6 +2312,7 @@ static void mwifiex_pcie_cleanup(struct mwifiex_adapter *adapter)
pci_release_region(pdev, 0); pci_release_region(pdev, 0);
pci_set_drvdata(pdev, NULL); pci_set_drvdata(pdev, NULL);
} }
kfree(card);
} }
/* /*
......
...@@ -196,7 +196,6 @@ mwifiex_sdio_remove(struct sdio_func *func) ...@@ -196,7 +196,6 @@ mwifiex_sdio_remove(struct sdio_func *func)
} }
mwifiex_remove_card(card->adapter, &add_remove_card_sem); mwifiex_remove_card(card->adapter, &add_remove_card_sem);
kfree(card);
} }
/* /*
...@@ -1745,7 +1744,6 @@ mwifiex_unregister_dev(struct mwifiex_adapter *adapter) ...@@ -1745,7 +1744,6 @@ mwifiex_unregister_dev(struct mwifiex_adapter *adapter)
sdio_claim_host(card->func); sdio_claim_host(card->func);
sdio_disable_func(card->func); sdio_disable_func(card->func);
sdio_release_host(card->func); sdio_release_host(card->func);
sdio_set_drvdata(card->func, NULL);
} }
} }
...@@ -1773,7 +1771,6 @@ static int mwifiex_register_dev(struct mwifiex_adapter *adapter) ...@@ -1773,7 +1771,6 @@ static int mwifiex_register_dev(struct mwifiex_adapter *adapter)
return ret; return ret;
} }
sdio_set_drvdata(func, card);
adapter->dev = &func->dev; adapter->dev = &func->dev;
...@@ -1801,6 +1798,8 @@ static int mwifiex_init_sdio(struct mwifiex_adapter *adapter) ...@@ -1801,6 +1798,8 @@ static int mwifiex_init_sdio(struct mwifiex_adapter *adapter)
int ret; int ret;
u8 sdio_ireg; u8 sdio_ireg;
sdio_set_drvdata(card->func, card);
/* /*
* Read the HOST_INT_STATUS_REG for ACK the first interrupt got * Read the HOST_INT_STATUS_REG for ACK the first interrupt got
* from the bootloader. If we don't do this we get a interrupt * 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,6 +1882,8 @@ static void mwifiex_cleanup_sdio(struct mwifiex_adapter *adapter)
kfree(card->mpa_rx.len_arr); kfree(card->mpa_rx.len_arr);
kfree(card->mpa_tx.buf); kfree(card->mpa_tx.buf);
kfree(card->mpa_rx.buf); kfree(card->mpa_rx.buf);
sdio_set_drvdata(card->func, NULL);
kfree(card);
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment