[PATCH RESEND 1/2] WPS: Keep the in-use network valid when removing a duplicate credential

Alejandro Pacheco alepacheco99 at gmail.com
Sat Oct 17 06:09:58 PDT 2026


wpas_wps_remove_dup_network() can remove the older network block when a
WPS M8 message delivers two credentials for the same network. The older
block may be the WPS network that was converted in place for the first
credential and is still used for the ongoing association. Removing it
cleared current_ssid, but left the EAPOL and WPA state machines
referencing the freed network block, and the following WPS completion
processing lost the connection to the new credential.

Move the in-use references to the new network block before removing the
older one.

Fixes: 741ed9fc2503 ("WPS: Remove duplicate networks after WPS")
Signed-off-by: Alejandro Pacheco <alepacheco99 at gmail.com>
---
Resent: the first posting of this patch
(<CAB8Pm=xpX1-z2n5tGWE7QD0AvAn1SdamsZpmMBUF37eyc27TAQ at mail.gmail.com>)
reached the list with its long lines wrapped, so it does not apply.
The patch is unchanged. This time the diff is attached as plain text so
that it arrives intact; git am takes this mail as it is.

 wpa_supplicant/wps_supplicant.c | 9 +++++++++
 1 file changed, 9 insertions(+)
-------------- next part --------------
diff --git a/wpa_supplicant/wps_supplicant.c b/wpa_supplicant/wps_supplicant.c
index 25a5598ce..334f6a1cb 100644
--- a/wpa_supplicant/wps_supplicant.c
+++ b/wpa_supplicant/wps_supplicant.c
@@ -26,6 +26,7 @@
 #include "wpa_supplicant_i.h"
 #include "driver_i.h"
 #include "notify.h"
+#include "wpas_glue.h"
 #include "bssid_ignore.h"
 #include "bss.h"
 #include "scan.h"
@@ -365,6 +366,14 @@ static void wpas_wps_remove_dup_network(struct wpa_supplicant *wpa_s,
 
 		/* Remove the duplicated older network entry. */
 		wpa_printf(MSG_DEBUG, "Remove duplicate network %d", ssid->id);
+		if (ssid == wpa_s->current_ssid) {
+			/* The older entry is the one used for the ongoing
+			 * association; continue with the new entry. */
+			wpa_s->current_ssid = new_ssid;
+			wpa_supplicant_rsn_supp_set_config(wpa_s, new_ssid);
+			eapol_sm_notify_config(wpa_s->eapol, &new_ssid->eap,
+					       NULL);
+		}
 		wpas_notify_network_removed(wpa_s, ssid);
 		wpa_config_remove_network(wpa_s->conf, ssid->id);
 	}


More information about the Hostap mailing list