Skip to contentSkip to conversation

wl1251: fix crash on remove due to premature kfree

PATCH New Grazvydas Ignotas 1 participant 2 messages Apr 26, 2012 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wl1251: fix crash on remove due to premature kfree

Currently SDIO glue frees it's own structure before calling wl1251_free_hw(), which in turn calls ieee80211_unregister_hw(). The later call may result in a need to communicate with the chip to stop it (as it happens now if the interface is still up before rmmod), which means calls are made back to the glue, resulting in freed memory access.

Fix this by freeing glue data last.

---
 drivers/net/wireless/wl1251/sdio.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/net/wireless/wl1251/sdio.c +1 -1
index f786942..1b851f6 100644
@@ -315,8 +315,8 @@ static void __devexit wl1251_sdio_remove(struct sdio_func *func)
 
 	if (wl->irq)
 		free_irq(wl->irq, wl);
-	kfree(wl_sdio);
 	wl1251_free_hw(wl);
+	kfree(wl_sdio);
 
 	sdio_claim_host(func);
 	sdio_release_irq(func);
Signature · 1 line
1.7.0.4
#1 lore raw

PATCH 1/1 wl1251: fix crash on remove due to leftover work item

This driver currently leaves elp_work behind when stopping, which occasionally results in data corruption because work function ends up accessing freed memory, typical symptoms of this are various worker_thread crashes. Fix it by cancelling elp_work.

---
 drivers/net/wireless/wl1251/main.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/net/wireless/wl1251/main.c +1 -0
index 41302c7..d1afb8e 100644
@@ -479,6 +479,7 @@ static void wl1251_op_stop(struct ieee80211_hw *hw)
 	cancel_work_sync(&wl->irq_work);
 	cancel_work_sync(&wl->tx_work);
 	cancel_work_sync(&wl->filter_work);
+	cancel_delayed_work_sync(&wl->elp_work);
 
 	mutex_lock(&wl->mutex);
 
Signature · 1 line
1.7.0.4