]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
mesh: Fix race condition in mesh mpm new peer handling
authorFelix Fietkau <nbd@nbd.name>
Sun, 17 Feb 2019 15:02:56 +0000 (16:02 +0100)
committerJouni Malinen <j@w1.fi>
Sat, 28 Dec 2019 18:56:03 +0000 (20:56 +0200)
When wpa_supplicant receives another new peer event before the first one
has been processed, it tries to add a station to the driver a second
time (which fails) and then tears down the station entry until another
event comes in.

Fix this by only adding a station to the driver if it didn't exist
already.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
wpa_supplicant/mesh_mpm.c

index 308366f64162d8179de805a20c277cabdf076088..c7c85929f561d989a26c168cb4a6ed3ddb847772 100644 (file)
@@ -710,11 +710,12 @@ static struct sta_info * mesh_mpm_add_peer(struct wpa_supplicant *wpa_s,
        }
 
        sta = ap_get_sta(data, addr);
-       if (!sta) {
-               sta = ap_sta_add(data, addr);
-               if (!sta)
-                       return NULL;
-       }
+       if (sta)
+               return NULL;
+
+       sta = ap_sta_add(data, addr);
+       if (!sta)
+               return NULL;
 
        /* Set WMM by default since Mesh STAs are QoS STAs */
        sta->flags |= WLAN_STA_WMM;