Commit e64add27 authored by Oleksij Rempel's avatar Oleksij Rempel Committed by John W. Linville

b43: do not call ieee80211_unregister_hw if we are not registred

this patch fixes kernel Oops on "rmmod b43" if firmware was not loaded:

BUG: unable to handle kernel NULL pointer dereference at 0000000000000088
IP: [<ffffffff8104e988>] drain_workqueue+0x25/0x142
PGD 153ac6067 PUD 153b82067 PMD 0
Oops: 0000 [#1] SMP
Signed-off-by: default avatarOleksij Rempel <bug-track@fisher-privat.net>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent d2c8b15d
...@@ -877,6 +877,10 @@ struct b43_wl { ...@@ -877,6 +877,10 @@ struct b43_wl {
* from the mac80211 subsystem. */ * from the mac80211 subsystem. */
u16 mac80211_initially_registered_queues; u16 mac80211_initially_registered_queues;
/* Set this if we call ieee80211_register_hw() and check if we call
* ieee80211_unregister_hw(). */
bool hw_registred;
/* We can only have one operating interface (802.11 core) /* We can only have one operating interface (802.11 core)
* at a time. General information about this interface follows. * at a time. General information about this interface follows.
*/ */
......
...@@ -2437,6 +2437,7 @@ static void b43_request_firmware(struct work_struct *work) ...@@ -2437,6 +2437,7 @@ static void b43_request_firmware(struct work_struct *work)
err = ieee80211_register_hw(wl->hw); err = ieee80211_register_hw(wl->hw);
if (err) if (err)
goto err_one_core_detach; goto err_one_core_detach;
wl->hw_registred = true;
b43_leds_register(wl->current_dev); b43_leds_register(wl->current_dev);
goto out; goto out;
...@@ -5299,6 +5300,7 @@ static struct b43_wl *b43_wireless_init(struct b43_bus_dev *dev) ...@@ -5299,6 +5300,7 @@ static struct b43_wl *b43_wireless_init(struct b43_bus_dev *dev)
hw->queues = modparam_qos ? B43_QOS_QUEUE_NUM : 1; hw->queues = modparam_qos ? B43_QOS_QUEUE_NUM : 1;
wl->mac80211_initially_registered_queues = hw->queues; wl->mac80211_initially_registered_queues = hw->queues;
wl->hw_registred = false;
hw->max_rates = 2; hw->max_rates = 2;
SET_IEEE80211_DEV(hw, dev->dev); SET_IEEE80211_DEV(hw, dev->dev);
if (is_valid_ether_addr(sprom->et1mac)) if (is_valid_ether_addr(sprom->et1mac))
...@@ -5370,12 +5372,15 @@ static void b43_bcma_remove(struct bcma_device *core) ...@@ -5370,12 +5372,15 @@ static void b43_bcma_remove(struct bcma_device *core)
* as the ieee80211 unreg will destroy the workqueue. */ * as the ieee80211 unreg will destroy the workqueue. */
cancel_work_sync(&wldev->restart_work); cancel_work_sync(&wldev->restart_work);
/* Restore the queues count before unregistering, because firmware detect B43_WARN_ON(!wl);
* might have modified it. Restoring is important, so the networking if (wl->current_dev == wldev && wl->hw_registred) {
* stack can properly free resources. */ /* Restore the queues count before unregistering, because firmware detect
wl->hw->queues = wl->mac80211_initially_registered_queues; * might have modified it. Restoring is important, so the networking
b43_leds_stop(wldev); * stack can properly free resources. */
ieee80211_unregister_hw(wl->hw); wl->hw->queues = wl->mac80211_initially_registered_queues;
b43_leds_stop(wldev);
ieee80211_unregister_hw(wl->hw);
}
b43_one_core_detach(wldev->dev); b43_one_core_detach(wldev->dev);
...@@ -5446,7 +5451,7 @@ static void b43_ssb_remove(struct ssb_device *sdev) ...@@ -5446,7 +5451,7 @@ static void b43_ssb_remove(struct ssb_device *sdev)
cancel_work_sync(&wldev->restart_work); cancel_work_sync(&wldev->restart_work);
B43_WARN_ON(!wl); B43_WARN_ON(!wl);
if (wl->current_dev == wldev) { if (wl->current_dev == wldev && wl->hw_registred) {
/* Restore the queues count before unregistering, because firmware detect /* Restore the queues count before unregistering, because firmware detect
* might have modified it. Restoring is important, so the networking * might have modified it. Restoring is important, so the networking
* stack can properly free resources. */ * stack can properly free resources. */
......
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