aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/mwifiex
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
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')
-rw-r--r--drivers/net/wireless/mwifiex/init.c3
-rw-r--r--drivers/net/wireless/mwifiex/main.c12
2 files changed, 10 insertions, 5 deletions
diff --git a/drivers/net/wireless/mwifiex/init.c b/drivers/net/wireless/mwifiex/init.c
index e05b417a3fae..1d0ec57a0143 100644
--- a/drivers/net/wireless/mwifiex/init.c
+++ b/drivers/net/wireless/mwifiex/init.c
@@ -382,7 +382,8 @@ mwifiex_free_adapter(struct mwifiex_adapter *adapter)
382 382
383 adapter->if_ops.cleanup_if(adapter); 383 adapter->if_ops.cleanup_if(adapter);
384 384
385 dev_kfree_skb_any(adapter->sleep_cfm); 385 if (adapter->sleep_cfm)
386 dev_kfree_skb_any(adapter->sleep_cfm);
386} 387}
387 388
388/* 389/*
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