Cumulative patch from commit dc1a341dec54c28c3351ee7edab9ccaf7b68861f

dc1a341 P2P: Add manufacturer info into D-Bus peer interface
3330395 P2P: Add P2P Cancel method over D-Bus interface
87d3c62 WPS: Add WPS Cancel method over D-Bus interface
eda9d84 P2P: Fix a potential memory leak in a P2P+NFC corner case
701d972 Add libwpa_client build option to use a dynamic library
ccad05a P2P: Restart group formation timer upon receiving new Inv Req
4d3be9c Postpone updating of wpa_s->current_bss till association event
3784c05 Extend hw_mode to support any band for offloaded ACS case
1b748e6 HS 2.0: hs20-client: Fix hostname extraction from URL
dba68f2 HS 2.0: Fix hs20_spp_server compile error
e4a43a9 HS 2.0: spp-client: Warn user if xml file cannot be found

Change-Id: If4acdda6f6e6a07bf87216d34b2c89486a4a3078
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c
index 80e4c2e..6ecd094 100644
--- a/src/ap/drv_callbacks.c
+++ b/src/ap/drv_callbacks.c
@@ -532,7 +532,7 @@
 static void hostapd_acs_channel_selected(struct hostapd_data *hapd,
 					 struct acs_selected_channels *acs_res)
 {
-	int ret;
+	int ret, i;
 
 	if (hapd->iconf->channel) {
 		wpa_printf(MSG_INFO, "ACS: Channel was already set to %d",
@@ -540,6 +540,24 @@
 		return;
 	}
 
+	if (!hapd->iface->current_mode) {
+		for (i = 0; i < hapd->iface->num_hw_features; i++) {
+			struct hostapd_hw_modes *mode =
+				&hapd->iface->hw_features[i];
+
+			if (mode->mode == acs_res->hw_mode) {
+				hapd->iface->current_mode = mode;
+				break;
+			}
+		}
+		if (!hapd->iface->current_mode) {
+			hostapd_logger(hapd, NULL, HOSTAPD_MODULE_IEEE80211,
+				       HOSTAPD_LEVEL_WARNING,
+				       "driver selected to bad hw_mode");
+			return;
+		}
+	}
+
 	hapd->iface->freq = hostapd_hw_get_freq(hapd, acs_res->pri_channel);
 
 	if (!acs_res->pri_channel) {