[PATCH 2/2] NAN: Fix maybe-uninitialized warning in nan_sec_rx()

Chaitanya Tata chaitanya.mgit at gmail.com
Thu Sep 10 13:39:48 PDT 2026


instance_id and capab are only set by nan_parse_sec() on some paths
(the else branch sources them from ndp_sec instead), which is enough
to defeat GCC's flow analysis at -Os: it flags both as possibly used
uninitialized when copied into ndp_sec->i_instance_id/i_capab, which
is fatal for any -Werror build.

Reproduced with plain gcc -Os -Wall -Werror=maybe-uninitialized (GCC
13.3.0), no special build options required. Initialize both at
declaration to keep such builds working.

Signed-off-by: Chaitanya Tata <Chaitanya.Tata at nordicsemi.no>
---
 src/nan/nan_sec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/nan/nan_sec.c b/src/nan/nan_sec.c
index 8561c7cd3..2ea267717 100644
--- a/src/nan/nan_sec.c
+++ b/src/nan/nan_sec.c
@@ -596,7 +596,7 @@ int nan_sec_rx(struct nan_data *nan, struct nan_peer *peer,
 	size_t shared_key_desc_len;
 	u16 info, desc, key_data_len;
 	size_t total_len;
-	u8 instance_id, cipher, capab, gtk_csid = NAN_CS_NONE;
+	u8 instance_id = 0, cipher, capab = 0, gtk_csid = NAN_CS_NONE;
 	u8 *pos;
 	int ret;
 
-- 
2.43.0




More information about the Hostap mailing list