From b898b655824a5553cc1a4dde5e8ed4d628aacc08 Mon Sep 17 00:00:00 2001 From: Hu Wang Date: Wed, 8 Aug 2018 11:21:05 +0800 Subject: [PATCH] nl80211: Do not ignore disconnect event in case of !drv->associated Commit 3f53c006c7d7362cf715ceaeda92c69d91ea7b63 ('nl80211: Ignore disconnect event in case of locally generated request') made wpa_supplicant ignore the next received disconnect event for cases where wpa_supplicant itself requested a disconnection. This can result in ignoring a disconnection notification in some cases. Considering a P2P Client receiving disconnect event from the kernel after a P2P group is started, drv->ignore_next_local_disconnect is cleared to 0, then wpa_driver_nl80211_disconnect() will be called during the removal of the group, in which drv->ignore_next_local_disconnect is set to 1 by mistake. Do not allow ignore_next_local_{disconnect,deauth} to be set to 1 if the driver is not in associated state (drv->associated is 0) to avoid this type of cases. Signed-off-by: Jouni Malinen --- src/drivers/driver_nl80211.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 26df43bb7..39a02d3ee 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -3133,6 +3133,7 @@ static int wpa_driver_nl80211_disconnect(struct wpa_driver_nl80211_data *drv, int reason_code) { int ret; + int drv_associated = drv->associated; wpa_printf(MSG_DEBUG, "%s(reason_code=%d)", __func__, reason_code); nl80211_mark_disconnected(drv); @@ -3143,7 +3144,7 @@ static int wpa_driver_nl80211_disconnect(struct wpa_driver_nl80211_data *drv, * For locally generated disconnect, supplicant already generates a * DEAUTH event, so ignore the event from NL80211. */ - drv->ignore_next_local_disconnect = ret == 0; + drv->ignore_next_local_disconnect = drv_associated && (ret == 0); return ret; } @@ -3154,6 +3155,7 @@ static int wpa_driver_nl80211_deauthenticate(struct i802_bss *bss, { struct wpa_driver_nl80211_data *drv = bss->drv; int ret; + int drv_associated = drv->associated; if (drv->nlmode == NL80211_IFTYPE_ADHOC) { nl80211_mark_disconnected(drv); @@ -3170,7 +3172,8 @@ static int wpa_driver_nl80211_deauthenticate(struct i802_bss *bss, * For locally generated deauthenticate, supplicant already generates a * DEAUTH event, so ignore the event from NL80211. */ - drv->ignore_next_local_deauth = ret == 0; + drv->ignore_next_local_deauth = drv_associated && (ret == 0); + return ret; }