[PATCH] common: fix for_each_link_default() without valid bitmap

Nicolas Escande nico.escande at gmail.com
Wed Mar 4 02:50:19 PST 2026


When using for_each_link_default() without a valid bitmap instead of iterating
only over the _def_idx passed as argument we iterate over all possible indexes
from _def_idx up to MAX_NUM_MLD_LINKS.

Fixes: 0d4288a005f5 ("nl80211: Use valid_links bitmask for bss->links array")
Signed-off-by: Nicolas Escande <nico.escande at gmail.com>
---
 src/utils/common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/utils/common.h b/src/utils/common.h
index 52fd6cf8bc95..4cb900ad2e7c 100644
--- a/src/utils/common.h
+++ b/src/utils/common.h
@@ -630,7 +630,7 @@ char * get_param(const char *cmd, const char *param);
 /* Iterate all links, or, if no link is defined, iterate given index */
 #define for_each_link_default(_links, _i, _def_idx)	\
 	for ((_i) = (_links) ? 0 : (_def_idx);		\
-	     (_i) < MAX_NUM_MLD_LINKS ||		\
+	     ((_links) && (_i) < MAX_NUM_MLD_LINKS) ||	\
 		     (!(_links) && (_i) == (_def_idx));	\
 	     (_i)++)					\
 		if (!(_links) || (_links) & BIT(_i))
-- 
2.53.0




More information about the Hostap mailing list