]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
wifi: mac80211: properly handle error in ieee80211_add_virtual_monitor
authorMiri Korenblit <miriam.rachel.korenblit@intel.com>
Fri, 20 Mar 2026 12:13:46 +0000 (14:13 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 24 Mar 2026 15:31:52 +0000 (16:31 +0100)
In case of an error in ieee80211_add_virtual_monitor,
SDATA_STATE_RUNNING should be cleared as it was set in this function.
Do it there instead of in the error path of ieee80211_do_open.

Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20260320141312.5546126313b1.I689dba2f54069b259702e8d246cedf79a73b82c6@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/iface.c

index 40ce0bb727267d7ebae2f092555eaeb644be0d56..232fc0b80e44cc693b97e33da0d0afa2e297334b 100644 (file)
@@ -1222,14 +1222,14 @@ int ieee80211_add_virtual_monitor(struct ieee80211_local *local,
                }
        }
 
-       set_bit(SDATA_STATE_RUNNING, &sdata->state);
-
        ret = ieee80211_check_queues(sdata, NL80211_IFTYPE_MONITOR);
        if (ret) {
                kfree(sdata);
                return ret;
        }
 
+       set_bit(SDATA_STATE_RUNNING, &sdata->state);
+
        mutex_lock(&local->iflist_mtx);
        rcu_assign_pointer(local->monitor_sdata, sdata);
        mutex_unlock(&local->iflist_mtx);
@@ -1242,6 +1242,7 @@ int ieee80211_add_virtual_monitor(struct ieee80211_local *local,
                mutex_unlock(&local->iflist_mtx);
                synchronize_net();
                drv_remove_interface(local, sdata);
+               clear_bit(SDATA_STATE_RUNNING, &sdata->state);
                kfree(sdata);
                return ret;
        }
@@ -1550,8 +1551,6 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
        sdata->bss = NULL;
        if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
                list_del(&sdata->u.vlan.list);
-       /* might already be clear but that doesn't matter */
-       clear_bit(SDATA_STATE_RUNNING, &sdata->state);
        return res;
 }