[PATCH 2/2] wpa_supplicant: Clear WPA/EAPOL config when the current network is removed
alepacheco99 at gmail.com
alepacheco99 at gmail.com
Thu Oct 15 17:16:31 PDT 2026
wpas_notify_network_removed() clears wpa_s->current_ssid when the
network block being removed is the current one, but the WPA and EAPOL
state machines keep their own pointers to that network block (the
network context and the EAP peer configuration).
wpa_supplicant_remove_network(), wpa_supplicant_remove_all_networks()
and wpas_clear_wps() clear these explicitly before freeing the block,
but some other paths that call wpas_notify_network_removed() and
wpa_config_remove_network() do not, so removing the current network on
one of those paths leaves the state machines pointing to freed memory.
Clear the WPA and EAPOL configuration at the same place current_ssid is
cleared so that every removal of the current network through this
notification drops these references together.
Signed-off-by: Alejandro Pacheco <alepacheco99 at gmail.com>
---
wpa_supplicant/notify.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/wpa_supplicant/notify.c b/wpa_supplicant/notify.c
index 18cd63113..13e201c46 100644
--- a/wpa_supplicant/notify.c
+++ b/wpa_supplicant/notify.c
@@ -20,6 +20,7 @@
#include "dbus/dbus_new.h"
#include "rsn_supp/wpa.h"
#include "rsn_supp/pmksa_cache.h"
+#include "eapol_supp/eapol_supp_sm.h"
#include "fst/fst.h"
#include "crypto/tls.h"
#include "bss.h"
@@ -412,8 +413,11 @@ void wpas_notify_network_removed(struct
wpa_supplicant *wpa_s,
wpa_s->next_ssid = NULL;
if (wpa_s->last_ssid == ssid)
wpa_s->last_ssid = NULL;
- if (wpa_s->current_ssid == ssid)
+ if (wpa_s->current_ssid == ssid) {
wpa_s->current_ssid = NULL;
+ wpa_sm_set_config(wpa_s->wpa, NULL);
+ eapol_sm_notify_config(wpa_s->eapol, NULL, NULL);
+ }
if (wpa_s->ml_connect_probe_ssid == ssid) {
wpa_s->ml_connect_probe_ssid = NULL;
wpa_s->ml_connect_probe_bss = NULL;
--
2.48.1
More information about the Hostap
mailing list