From 084b3d2f8a85ef6e64ecf1f7beec077ca858f516 Mon Sep 17 00:00:00 2001 From: Vamsi Krishna Date: Thu, 3 Dec 2020 22:15:29 +0530 Subject: [PATCH] Drop unexpected connection event while disconnected If there is a disconnect command from wpa_supplicant immediately after the driver sends a connection event to userspace but before that event is received and processed by wpa_supplicant, wpa_supplicant processes the disconnect command and a self-generated disconnected event first followed by the connected event received from the driver. As a result wpa_supplicant moves to the WPA_COMPLETED state. Whereas the driver processes the disconnect command received from wpa_supplicant after it sends the connected event and moves to the disconnected state. Due to this race between the disconnect command from wpa_supplicant and the connected event from the driver, wpa_supplicant is moving to the connected state though the driver is moving to the disconnected state which results in abnormal functionality. Ignore the connection event coming from the driver when wpa_supplicant is not trying to connect after a disconnect command is issued but before the next connect command is issued to fix the above mentioned race condition. Signed-off-by: Jouni Malinen --- wpa_supplicant/events.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 89e6e7306..fa8f5e1c0 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -4715,6 +4715,11 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event, break; } #endif /* CONFIG_TESTING_OPTIONS */ + if (wpa_s->disconnected) { + wpa_printf(MSG_INFO, + "Ignore unexpected EVENT_ASSOC in disconnected state"); + break; + } wpa_supplicant_event_assoc(wpa_s, data); wpa_s->assoc_status_code = WLAN_STATUS_SUCCESS; if (data && -- 2.39.2