mac80211: check for MCS in ieee80211_duration before fetching chanctx
authorFelix Fietkau <nbd@nbd.name>
Wed, 14 Dec 2016 19:46:57 +0000 (20:46 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Thu, 15 Dec 2016 10:07:52 +0000 (11:07 +0100)
Makes the code a bit more efficient

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/tx.c

index 058652d000d96d707d2b7957f49c520d05ce8fdb..4dea18be385c068d26cb1ddd5cab409c5fb29e53 100644 (file)
@@ -64,6 +64,10 @@ static __le16 ieee80211_duration(struct ieee80211_tx_data *tx,
        struct ieee80211_chanctx_conf *chanctx_conf;
        u32 rate_flags = 0;
 
+       /* assume HW handles this */
+       if (tx->rate.flags & (IEEE80211_TX_RC_MCS | IEEE80211_TX_RC_VHT_MCS))
+               return 0;
+
        rcu_read_lock();
        chanctx_conf = rcu_dereference(tx->sdata->vif.chanctx_conf);
        if (chanctx_conf) {
@@ -72,10 +76,6 @@ static __le16 ieee80211_duration(struct ieee80211_tx_data *tx,
        }
        rcu_read_unlock();
 
-       /* assume HW handles this */
-       if (tx->rate.flags & (IEEE80211_TX_RC_MCS | IEEE80211_TX_RC_VHT_MCS))
-               return 0;
-
        /* uh huh? */
        if (WARN_ON_ONCE(tx->rate.idx < 0))
                return 0;