]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
mac80211: fix work race
authorJohannes Berg <johannes@sipsolutions.net>
Wed, 10 Sep 2008 22:01:50 +0000 (00:01 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 15 Sep 2008 20:48:20 +0000 (16:48 -0400)
When we stop an interface, the work on it may still be pending
or running. We do cancel the timer, but we do not currently
protect against the work struct. The race is very unlikely to
hit -- it'll happen only when the driver is using mac80211's
workqueue to run long-running tasks and the sta/mesh works are
delayed for quite a bit.

This patch fixes it by cancelling the work explicitly.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
net/mac80211/main.c
net/mac80211/mesh.c

index 522fe61764853082accb3e64168179d420fa7ba6..ebdec7106d6365af4b25c16f3d7c591322e4fd73 100644 (file)
@@ -547,6 +547,14 @@ static int ieee80211_stop(struct net_device *dev)
                sdata->u.sta.state = IEEE80211_STA_MLME_DISABLED;
                memset(sdata->u.sta.bssid, 0, ETH_ALEN);
                del_timer_sync(&sdata->u.sta.timer);
+               /*
+                * If the timer fired while we waited for it, it will have
+                * requeued the work. Now the work will be running again
+                * but will not rearm the timer again because it checks
+                * whether the interface is running, which, at this point,
+                * it no longer is.
+                */
+               cancel_work_sync(&sdata->u.sta.work);
                /*
                 * When we get here, the interface is marked down.
                 * Call synchronize_rcu() to wait for the RX path
index 9e47725cc59218743bca76a0085bc46785322d55..a0141f5ff184db17d10a020e0c1c7676b6dfbe9c 100644 (file)
@@ -448,6 +448,15 @@ void ieee80211_start_mesh(struct ieee80211_sub_if_data *sdata)
 void ieee80211_stop_mesh(struct ieee80211_sub_if_data *sdata)
 {
        del_timer_sync(&sdata->u.mesh.housekeeping_timer);
+       /*
+        * If the timer fired while we waited for it, it will have
+        * requeued the work. Now the work will be running again
+        * but will not rearm the timer again because it checks
+        * whether the interface is running, which, at this point,
+        * it no longer is.
+        */
+       cancel_work_sync(&sdata->u.mesh.work);
+
        /*
         * When we get here, the interface is marked down.
         * Call synchronize_rcu() to wait for the RX path