[PATCH net] Octeontx2-af: Fix negative array index read warning
From: Chandra Mohan Sundar <hidden>
Date: 2025-08-10 18:03:55
Also in:
linux-kernel-mentees, lkml
Subsystem:
marvell octeontx2 rvu admin function driver, networking drivers, the rest · Maintainers:
Sunil Goutham, Linu Cherian, Geetha sowjanya, hariprasad, Subbaraya Sundeep, Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds
The cgx_get_cgxid function may return a negative value.
Using this value directly as an array index triggers Coverity warnings.
Validate the returned value and handle the case gracefully.
Signed-off-by: Chandra Mohan Sundar <redacted>
---
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
index 8375f18c8e07..b14de93a2481 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
@@ -3005,6 +3005,8 @@ static int cgx_print_fwdata(struct seq_file *s, int lmac_id)
return -EAGAIN;
cgx_id = cgx_get_cgxid(cgxd);
+ if (cgx_id < 0)
+ return -EINVAL;
if (rvu->hw->lmac_per_cgx == CGX_LMACS_USX)
fwdata = &rvu->fwdata->cgx_fw_data_usx[cgx_id][lmac_id];
--
2.43.0