nl80211: Do not ignore disconnect event in case of !drv->associated

Commit 3f53c006c7 ('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 <jouni@codeaurora.org>
This commit is contained in:
Hu Wang 2018-08-08 11:21:05 +08:00 committed by Jouni Malinen
parent 2697e85ea9
commit b898b65582

View file

@ -3133,6 +3133,7 @@ static int wpa_driver_nl80211_disconnect(struct wpa_driver_nl80211_data *drv,
int reason_code) int reason_code)
{ {
int ret; int ret;
int drv_associated = drv->associated;
wpa_printf(MSG_DEBUG, "%s(reason_code=%d)", __func__, reason_code); wpa_printf(MSG_DEBUG, "%s(reason_code=%d)", __func__, reason_code);
nl80211_mark_disconnected(drv); 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 * For locally generated disconnect, supplicant already generates a
* DEAUTH event, so ignore the event from NL80211. * 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; return ret;
} }
@ -3154,6 +3155,7 @@ static int wpa_driver_nl80211_deauthenticate(struct i802_bss *bss,
{ {
struct wpa_driver_nl80211_data *drv = bss->drv; struct wpa_driver_nl80211_data *drv = bss->drv;
int ret; int ret;
int drv_associated = drv->associated;
if (drv->nlmode == NL80211_IFTYPE_ADHOC) { if (drv->nlmode == NL80211_IFTYPE_ADHOC) {
nl80211_mark_disconnected(drv); 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 * For locally generated deauthenticate, supplicant already generates a
* DEAUTH event, so ignore the event from NL80211. * 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; return ret;
} }