[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250810180339.228231-1-chandramohan.explore@gmail.com>
Date: Sun, 10 Aug 2025 23:33:27 +0530
From: Chandra Mohan Sundar <chandramohan.explore@...il.com>
To: sgoutham@...vell.com,
lcherian@...vell.com,
gakula@...vell.com,
jerinj@...vell.com,
hkelam@...vell.com,
sbhatta@...vell.com,
andrew+netdev@...n.ch,
davem@...emloft.net,
edumazet@...gle.com,
kuba@...nel.org,
pabeni@...hat.com,
shuah@...nel.org
Cc: Chandra Mohan Sundar <chandramohan.explore@...il.com>,
netdev@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux-kernel-mentees@...ts.linux.dev
Subject: [PATCH net] Octeontx2-af: Fix negative array index read warning
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 <chandramohan.explore@...il.com>
---
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
Powered by blists - more mailing lists