octeontx2-af: initialize lmac_bmap in rvu_mcs_set_lmac_bmap()
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.
--- 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
@@ -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
Quoted 6 lines · Karl Mehltretter
rvu_mcs_set_lmac_bmap()declareslmac_bmapwithout initializing it and only sets bits for valid lmacs withset_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 intomcs->hw->lmac_bmap.
Quoted 7 lines
Initialize
lmac_bmapto 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-5Signed-off-by Karl Mehltretter <[email protected]>
Thank you.
Quoted 6 lines · Karl Mehltretter
rvu_mcs_set_lmac_bmap()declareslmac_bmapwithout initializing it and only sets bits for valid lmacs withset_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 intomcs->hw->lmac_bmap.
Quoted 7 lines
Initialize
lmac_bmapto 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-5Signed-off-by Karl Mehltretter <[email protected]>
Quoted 9 lines · On Wed, 12 Aug 2026 08:07:30 +0200 Karl Mehltretter wrote:
rvu_mcs_set_lmac_bmap()declareslmac_bmapwithout initializing it and only sets bits for valid lmacs withset_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 intomcs->hw->lmac_bmap.Initialize
lmac_bmapto 0 so only valid lmacs are marked.Found with Clang's -Wconditional-uninitialized.
Applied, thanks!