+- hapd->iconf = newconf;
+- hapd->conf = &newconf->bss[j];
++ hapd->iconf = iface->conf;
++ hapd->conf = &iface->conf->bss[j];
++
++ if (hostapd_set_freq(hapd, conf->hw_mode, iface->freq,
++ conf->channel,
++ conf->ieee80211n,
++ conf->ieee80211ac,
++ conf->secondary_channel,
++ conf->vht_oper_chwidth,
++ conf->vht_oper_centr_freq_seg0_idx,
++ conf->vht_oper_centr_freq_seg1_idx)) {
++ wpa_printf(MSG_ERROR, "Could not set channel for "
++ "kernel driver");
++ }
++
+ hostapd_reload_bss(hapd);
+ }
+
+- hostapd_config_free(oldconf);
+-
++ if (oldconf)
++ hostapd_config_free(oldconf);
+
+ return 0;
+ }
+--- a/src/drivers/driver_nl80211.c
++++ b/src/drivers/driver_nl80211.c
+@@ -6466,7 +6466,7 @@ static int wpa_driver_nl80211_set_freq(s
+
+ nl80211_cmd(drv, msg, 0, NL80211_CMD_SET_WIPHY);
+
+- NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, drv->ifindex);
++ NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, bss->ifindex);
+ NLA_PUT_U32(msg, NL80211_ATTR_WIPHY_FREQ, freq->freq);
+ if (freq->vht_enabled) {
+ switch (freq->bandwidth) {