mac80211: Fixing sparse warning at sta_info.c
authorYogesh Ashok Powar <yogesh.powar@gmail.com>
Fri, 16 Dec 2011 06:17:15 +0000 (11:47 +0530)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 19 Dec 2011 20:06:09 +0000 (15:06 -0500)
The commit 42624d4913a00219a8fdbb4bafd634d1d843be85
created following sparse warning
>net/mac80211/sta_info.c:965:24: warning: incorrect type in assignment (different address spaces)
>net/mac80211/sta_info.c:965:24:    expected struct tid_ampdu_tx *tid_tx
>net/mac80211/sta_info.c:965:24:    got struct tid_ampdu_tx [noderef] <asn:4>*<noident>

Making use of rcu_dereference_protected to fix the problem.

V2:
 - Replacing rcu_dereference with rcu_dereference_protected
   as suggested by Johannes.
 - Adding mutex_lock/unlock to satisfy the condition at
   rcu_dereference_protected

Cc: Nishant Sarmukadam <nishants@marvell.com>
Reported-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Yogesh Ashok Powar <yogeshp@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
net/mac80211/sta_info.c

index 2db01e9541e7ea579ebde1ef8370f75e646c0320..3d01abb2b8137b7039c786d1b3f09221d7a02fb4 100644 (file)
@@ -822,10 +822,13 @@ static int __must_check __sta_info_destroy(struct sta_info *sta)
         * until the aggregation stop completes. Refer
         * http://thread.gmane.org/gmane.linux.kernel.wireless.general/81936
         */
+
+       mutex_lock(&sta->ampdu_mlme.mtx);
+
        for (i = 0; i < STA_TID_NUM; i++) {
-               if (!sta->ampdu_mlme.tid_tx[i])
+               tid_tx = rcu_dereference_protected_tid_tx(sta, i);
+               if (!tid_tx)
                        continue;
-               tid_tx = sta->ampdu_mlme.tid_tx[i];
                if (skb_queue_len(&tid_tx->pending)) {
 #ifdef CONFIG_MAC80211_HT_DEBUG
                        wiphy_debug(local->hw.wiphy, "TX A-MPDU  purging %d "
@@ -837,6 +840,8 @@ static int __must_check __sta_info_destroy(struct sta_info *sta)
                kfree_rcu(tid_tx, rcu_head);
        }
 
+       mutex_unlock(&sta->ampdu_mlme.mtx);
+
        sta_info_free(local, sta);
 
        return 0;