DECLARE_MAC_BUF(mac);
        DECLARE_MAC_BUF(mac2);
 
-       beacon_timestamp = le64_to_cpu(mgmt->u.beacon.timestamp);
+       if (elems->ds_params && elems->ds_params_len == 1)
+               freq = ieee80211_channel_to_frequency(elems->ds_params[0]);
+       else
+               freq = rx_status->freq;
+
+       channel = ieee80211_get_channel(local->hw.wiphy, freq);
+
+       if (!channel || channel->flags & IEEE80211_CHAN_DISABLED)
+               return;
 
        if (ieee80211_vif_is_mesh(&sdata->vif) && elems->mesh_id &&
            elems->mesh_config && mesh_matches_local(elems, sdata)) {
                rcu_read_unlock();
        }
 
-       if (elems->ds_params && elems->ds_params_len == 1)
-               freq = ieee80211_channel_to_frequency(elems->ds_params[0]);
-       else
-               freq = rx_status->freq;
-
-       channel = ieee80211_get_channel(local->hw.wiphy, freq);
-
-       if (!channel || channel->flags & IEEE80211_CHAN_DISABLED)
-               return;
-
 #ifdef CONFIG_MAC80211_MESH
        if (elems->mesh_config)
                bss = ieee80211_rx_mesh_bss_get(local, elems->mesh_id,
 
        bss->band = band;
 
+       beacon_timestamp = le64_to_cpu(mgmt->u.beacon.timestamp);
+
        bss->timestamp = beacon_timestamp;
        bss->last_update = jiffies;
        bss->signal = rx_status->signal;