Skip to content

Commit

Permalink
mac80211: Do not free net device after it is unregistered.
Browse files Browse the repository at this point in the history
The error path in ieee80211_register_hw() may call the unregister_netdev()
and right after it - the free_netdev(), which is wrong, since the
unregister releases the device itself.

So the proposed fix is to NULL the local->mdev after unregister is done
and check this before calling free_netdev().

I checked - no code uses the local->mdev after unregister in this error
path (but even if some did this would be a BUG).

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Pavel Emelyanov authored and David S. Miller committed May 5, 2008
1 parent e340a90 commit 339a7c4
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions net/mac80211/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1766,15 +1766,18 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
fail_rate:
ieee80211_debugfs_remove_netdev(IEEE80211_DEV_TO_SUB_IF(local->mdev));
unregister_netdevice(local->mdev);
local->mdev = NULL;
fail_dev:
rtnl_unlock();
sta_info_stop(local);
fail_sta_info:
debugfs_hw_del(local);
destroy_workqueue(local->hw.workqueue);
fail_workqueue:
ieee80211_if_free(local->mdev);
local->mdev = NULL;
if (local->mdev != NULL) {
ieee80211_if_free(local->mdev);
local->mdev = NULL;
}
fail_mdev_alloc:
wiphy_unregister(local->hw.wiphy);
return result;
Expand Down

0 comments on commit 339a7c4

Please sign in to comment.