From 10122e951df2e9b50ae2bd2daef9e7716756fb6e Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 2 Mar 2024 21:04:30 +0200 Subject: [PATCH] P2P: Fix pri/sec channel switch skipping for GO Use of wpa_s->p2p_go_no_pri_sec_switch needs to be conditional on CONFIG_P2P being defined for the build to avoid a compilation error and ssid->p2p_group to avoid using this for non-P2P AP mode case in wpa_supplicant. Furthermore, it is better to clear this flag when stopping a P2P GO to reduce risk of this getting used for a separate instance of starting a GO. Fixes: b18d95759375 ("P2P: Disable pri/sec channel switch for GO with forced frequency") Signed-off-by: Jouni Malinen --- wpa_supplicant/ap.c | 9 +++++++-- wpa_supplicant/p2p_supplicant.c | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c index 11bf53900..69a0e5ee1 100644 --- a/wpa_supplicant/ap.c +++ b/wpa_supplicant/ap.c @@ -440,9 +440,14 @@ int wpa_supplicant_conf_ap_ht(struct wpa_supplicant *wpa_s, } } - if (wpa_s->p2p_go_no_pri_sec_switch) { +#ifdef CONFIG_P2P + if (ssid->p2p_group && wpa_s->p2p_go_no_pri_sec_switch) { conf->no_pri_sec_switch = 1; - } else if (conf->secondary_channel) { + return 0; + } +#endif /* CONFIG_P2P */ + + if (conf->secondary_channel) { struct wpa_supplicant *iface; for (iface = wpa_s->global->ifaces; iface; iface = iface->next) diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index f8e903362..cfa4f4c88 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -1100,6 +1100,8 @@ static int wpas_p2p_group_delete(struct wpa_supplicant *wpa_s, os_memset(wpa_s->go_dev_addr, 0, ETH_ALEN); + wpa_s->p2p_go_no_pri_sec_switch = 0; + return 0; }