Skip to content

Commit 0617aa9

Browse files
Dan Carpenterdavem330
authored andcommitted
octeontx2-af: Fix uninitialized variable in debugfs
If rvu_get_blkaddr() fails, then this rvu_cgx_nix_cuml_stats() returns zero and we write some uninitialized data into the debugfs output. On the error paths, the use of the uninitialized "*stat" is harmless, but it will lead to a Smatch warning (static analysis) and a UBSan warning (runtime analysis) so we should prevent that as well. Fixes: f967488 ("octeontx2-af: Add per CGX port level NIX Rx/Tx counters") Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 039fccc commit 0617aa9

File tree

1 file changed

+2
-1
lines changed
  • drivers/net/ethernet/marvell/octeontx2/af

1 file changed

+2
-1
lines changed

drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,8 @@ int rvu_cgx_nix_cuml_stats(struct rvu *rvu, void *cgxd, int lmac_id,
608608
u16 pcifunc;
609609
int pf, lf;
610610

611+
*stat = 0;
612+
611613
if (!cgxd || !rvu)
612614
return -EINVAL;
613615

@@ -624,7 +626,6 @@ int rvu_cgx_nix_cuml_stats(struct rvu *rvu, void *cgxd, int lmac_id,
624626
return 0;
625627
block = &rvu->hw->block[blkaddr];
626628

627-
*stat = 0;
628629
for (lf = 0; lf < block->lf.max; lf++) {
629630
/* Check if a lf is attached to this PF or one of its VFs */
630631
if (!((block->fn_map[lf] & ~RVU_PFVF_FUNC_MASK) == (pcifunc &

0 commit comments

Comments
 (0)