[PATCH 1/3] station: fix use-after-free in preauthenticate_cb

Suchir Kavi <[email protected]> Wed, 15 Jul 2026 19:34:42 -0700
Newsgroups dev.linux.lists.iwd
Message-ID <[email protected]>
station_preauthenticate_cb() falls through its error branch: after
unreffing new_hs on a failed station_transition_reassociate(), it
proceeds to swap station->hs to a reference on the freed handshake.
Return instead.

Assisted-by: Claude:claude-fable-5
---
 src/station.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/station.c b/src/station.c
index 8fcf8c70..0b2d7dc6 100644
--- a/src/station.c
+++ b/src/station.c
@@ -2598,6 +2598,7 @@ static void station_preauthenticate_cb(struct netdev *netdev,
 	if (station_transition_reassociate(station, bss, new_hs) < 0) {
 		handshake_state_unref(new_hs);
 		station_roam_failed(station);
+		return;
 	}
 
 	handshake_state_unref(station->hs);
-- 
2.54.0