Regardless of how the AP mode is disabled, wpa_supplicant_ap_deinit() must be called. Make sure this happens on all paths by calling the deinit function from wpa_supplicant_mark_disassoc().
@@ -475,6 +475,7 @@ void wpa_supplicant_ap_deinit(struct wpa_supplicant *wpa_s)
wpa_s->current_ssid = NULL;
wpa_s->assoc_freq = 0;
+ wpa_s->reassociated_connection = 0;
#ifdef CONFIG_P2P
if (wpa_s->ap_iface->bss)
wpa_s->ap_iface->bss[0]->p2p_group = NULL;
@@ -118,6 +118,10 @@ void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s)
wpa_s->ibss_rsn = NULL;
#endif /* CONFIG_IBSS_RSN */
+#ifdef CONFIG_AP
+ wpa_supplicant_ap_deinit(wpa_s);
+#endif /* CONFIG_AP */
+
if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED)
return;