From a7e23d28ccd14800f0dd3f12bf0d053df6987fe7 Mon Sep 17 00:00:00 2001
From: JasonHuang <Jason.Huang-EE@infineon.com>
Date: Tue, 19 Jul 2022 01:44:19 -0500
Subject: [PATCH 31/49] P2P: Fixes Scan trigger failed, once GC invited by GO

It's regression between 2.9 and 2.10. The 5g frequencys be
repeatedly added to the list, then nl80211 driver will return
-22 (Invalid argument).

Signed-off-by: JasonHuang <Jason.Huang-EE@infineon.com>
---
 wpa_supplicant/scan.c | 28 ++++++++++------------------
 1 file changed, 10 insertions(+), 18 deletions(-)

diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c
index b0094ca6c..fb41aa718 100644
--- a/wpa_supplicant/scan.c
+++ b/wpa_supplicant/scan.c
@@ -1365,28 +1365,20 @@ scan:
 	    (wpa_s->p2p_in_invitation || wpa_s->p2p_in_provisioning) &&
 	    !is_p2p_allow_6ghz(wpa_s->global->p2p) &&
 	    is_6ghz_supported(wpa_s)) {
-		int i;
 
-		/* Exclude 5 GHz channels from the full scan for P2P connection
+		/* Exclude 6 GHz channels from the full scan for P2P connection
 		 * since the 6 GHz band is disabled for P2P uses. */
 		wpa_printf(MSG_DEBUG,
 			   "P2P: 6 GHz disabled - update the scan frequency list");
-		for (i = 0; i < wpa_s->hw.num_modes; i++) {
-			if (wpa_s->hw.modes[i].num_channels == 0)
-				continue;
-			if (wpa_s->hw.modes[i].mode == HOSTAPD_MODE_IEEE80211G)
-				wpa_add_scan_freqs_list(
-					wpa_s, HOSTAPD_MODE_IEEE80211G,
-					&params, false);
-			if (wpa_s->hw.modes[i].mode == HOSTAPD_MODE_IEEE80211A)
-				wpa_add_scan_freqs_list(
-					wpa_s, HOSTAPD_MODE_IEEE80211A,
-					&params, false);
-			if (wpa_s->hw.modes[i].mode == HOSTAPD_MODE_IEEE80211AD)
-				wpa_add_scan_freqs_list(
-					wpa_s, HOSTAPD_MODE_IEEE80211AD,
-					&params, false);
-		}
+		wpa_add_scan_freqs_list(
+			wpa_s, HOSTAPD_MODE_IEEE80211G,
+			&params, false);
+		wpa_add_scan_freqs_list(
+			wpa_s, HOSTAPD_MODE_IEEE80211A,
+			&params, false);
+		wpa_add_scan_freqs_list(
+			wpa_s, HOSTAPD_MODE_IEEE80211AD,
+			&params, false);
 	}
 #endif /* CONFIG_P2P */
 
-- 
2.17.1

