From 12a95743425fdf100dbb714416fd11c6beec9a01 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 22 Dec 2023 10:57:04 +0200 Subject: [PATCH] nl80211: Fix AP deinit path (link removal) in error cases If the interface initialization fails, no links might be set when calling the deinit functions. Those functions need to be prepared for bss->n_links being 0. Fixes: 859cbc396fc0 ("nl80211: Remove links when stopping AP MLD in hostapd") Signed-off-by: Jouni Malinen --- src/drivers/driver_nl80211.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 4bebd6ed3..0f4259c1c 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -9372,6 +9372,9 @@ static void nl80211_remove_links(struct i802_bss *bss) int ret; u8 link_id; + if (bss->n_links == 0) + return; + while (bss->links[0].link_id != NL80211_DRV_LINK_ID_NA) { struct i802_link *link = &bss->links[0];