diff mbox series

[v2] wpa_supplicant: fix race condition in mesh mpm new peer handling

Message ID 20190217150256.52695-1-nbd@nbd.name
State Accepted
Headers show
Series [v2] wpa_supplicant: fix race condition in mesh mpm new peer handling | expand

Commit Message

Felix Fietkau Feb. 17, 2019, 3:02 p.m. UTC
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 | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Comments

Jouni Malinen Dec. 28, 2019, 7:52 p.m. UTC | #1
On Sun, Feb 17, 2019 at 04:02:56PM +0100, Felix Fietkau wrote:
> 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.

Thanks, applied.
diff mbox series

Patch

diff --git a/wpa_supplicant/mesh_mpm.c b/wpa_supplicant/mesh_mpm.c
index 44859396c..2d2c47d76 100644
--- a/wpa_supplicant/mesh_mpm.c
+++ b/wpa_supplicant/mesh_mpm.c
@@ -685,11 +685,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;