aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/mwifiex/main.c
diff options
context:
space:
mode:
authorAmitkumar Karwar <akarwar@marvell.com>2012-02-03 23:34:02 -0500
committerJohn W. Linville <linville@tuxdriver.com>2012-02-06 11:34:02 -0500
commit2da8cbf8a6b454296c9db7b57cac72d5a39e3aa7 (patch)
tree6c936d599c04ebf8e4979162de896c6017d64a48 /drivers/net/wireless/mwifiex/main.c
parent07445f688218a48bde72316aed9de4fdcc173131 (diff)
mwifiex: add NULL checks in driver unload path
If driver load is failed, sometimes few pointers may remain uninitialized ex. priv->wdev, priv->netdev, adapter->sleep_cfm This will cause NULL pointer dereferance while unloading the driver. Signed-off-by: Amitkumar Karwar <akarwar@marvell.com> Signed-off-by: Kiran Divekar <dkiran@marvell.com> Signed-off-by: Bing Zhao <bzhao@marvell.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/mwifiex/main.c')
-rw-r--r--drivers/net/wireless/mwifiex/main.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/net/wireless/mwifiex/main.c b/drivers/net/wireless/mwifiex/main.c
index 84be196188cc..b728f54451e4 100644
--- a/drivers/net/wireless/mwifiex/main.c
+++ b/drivers/net/wireless/mwifiex/main.c
@@ -822,7 +822,9 @@ int mwifiex_remove_card(struct mwifiex_adapter *adapter, struct semaphore *sem)
822 continue; 822 continue;
823 823
824 rtnl_lock(); 824 rtnl_lock();
825 mwifiex_del_virtual_intf(priv->wdev->wiphy, priv->netdev); 825 if (priv->wdev && priv->netdev)
826 mwifiex_del_virtual_intf(priv->wdev->wiphy,
827 priv->netdev);
826 rtnl_unlock(); 828 rtnl_unlock();
827 } 829 }
828 830
@@ -830,9 +832,11 @@ int mwifiex_remove_card(struct mwifiex_adapter *adapter, struct semaphore *sem)
830 if (!priv) 832 if (!priv)
831 goto exit_remove; 833 goto exit_remove;
832 834
833 wiphy_unregister(priv->wdev->wiphy); 835 if (priv->wdev) {
834 wiphy_free(priv->wdev->wiphy); 836 wiphy_unregister(priv->wdev->wiphy);
835 kfree(priv->wdev); 837 wiphy_free(priv->wdev->wiphy);
838 kfree(priv->wdev);
839 }
836 840
837 mwifiex_terminate_workqueue(adapter); 841 mwifiex_terminate_workqueue(adapter);
838 842