Skip to contentSkip to conversation

octeontx2-af: initialize lmac_bmap in rvu_mcs_set_lmac_bmap()

PATCH Applied Karl Mehltretter 4 participants 4 messages Aug 12 – Aug 17

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 octeontx2-af: initialize lmac_bmap in rvu_mcs_set_lmac_bmap()

rvu_mcs_set_lmac_bmap() declares lmac_bmap without initializing it and only sets bits for valid lmacs with set_bit(), which ORs into the word without clearing it first. Bits for invalid or skipped ports keep whatever was on the stack, and the garbage is stored into mcs->hw->lmac_bmap.

Initialize lmac_bmap to 0 so only valid lmacs are marked.

Found with Clang's -Wconditional-uninitialized.

Fixes ca7f49ff8846 ("octeontx2-af: cn10k: Introduce driver for macsec block.")
Assisted-by Claude:claude-fable-5
---
 drivers/net/ethernet/marvell/octeontx2/af/mcs_rvu_if.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/af/mcs_rvu_if.c +1 -1
index d98b49f47970b..fce22e314cac0 100644
@@ -856,7 +856,7 @@ int rvu_mbox_handler_mcs_ctrl_pkt_rule_write(struct rvu *rvu,
 static void rvu_mcs_set_lmac_bmap(struct rvu *rvu)
 {
 	struct mcs *mcs = mcs_get_pdata(0);
-	unsigned long lmac_bmap;
+	unsigned long lmac_bmap = 0;
 	int cgx, lmac, port;
 
 	for (port = 0; port < mcs->hw->lmac_cnt; port++) {
Signature · 1 line
2.53.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Karl Mehltretter

rvu_mcs_set_lmac_bmap() declares lmac_bmap without initializing it and only sets bits for valid lmacs with set_bit(), which ORs into the word without clearing it first. Bits for invalid or skipped ports keep whatever was on the stack, and the garbage is stored into mcs->hw->lmac_bmap.

Quoted 7 lines

Initialize lmac_bmap to 0 so only valid lmacs are marked.

Found with Clang's -Wconditional-uninitialized.

Fixes ca7f49ff8846 ("octeontx2-af: cn10k: Introduce driver for macsec block.")
Assisted-by Claude:claude-fable-5

Thank you.

reviewer Reviewed-by on v1 1/1
#2 lore raw
In reply to Karl Mehltretter
Quoted 6 lines · Karl Mehltretter

rvu_mcs_set_lmac_bmap() declares lmac_bmap without initializing it and only sets bits for valid lmacs with set_bit(), which ORs into the word without clearing it first. Bits for invalid or skipped ports keep whatever was on the stack, and the garbage is stored into mcs->hw->lmac_bmap.

Quoted 7 lines

Initialize lmac_bmap to 0 so only valid lmacs are marked.

Found with Clang's -Wconditional-uninitialized.

Fixes ca7f49ff8846 ("octeontx2-af: cn10k: Introduce driver for macsec block.")
Assisted-by Claude:claude-fable-5
maintainer Applied
#3 lore raw
In reply to Karl Mehltretter
Quoted 9 lines · On Wed, 12 Aug 2026 08:07:30 +0200 Karl Mehltretter wrote:

rvu_mcs_set_lmac_bmap() declares lmac_bmap without initializing it and only sets bits for valid lmacs with set_bit(), which ORs into the word without clearing it first. Bits for invalid or skipped ports keep whatever was on the stack, and the garbage is stored into mcs->hw->lmac_bmap.

Initialize lmac_bmap to 0 so only valid lmacs are marked.

Found with Clang's -Wconditional-uninitialized.

Applied, thanks!