Netdev List
 help / color / mirror / Atom feed
* [PATCH net] octeontx2-af: validate MCS blocks before initialization
@ 2026-09-13 12:52 Slavin Liu
  0 siblings, 0 replies; only message in thread
From: Slavin Liu @ 2026-09-13 12:52 UTC (permalink / raw)
  To: sgoutham, rkannoth, gakula, sbhatta, andrew+netdev, davem,
	edumazet, kuba, pabeni
  Cc: netdev, linux-kernel, bolin.liu

The MCS count is a maximum successful ID plus one, not proof of a
dense device set. Validate the complete range before programming any
block, so a failed lower-ID probe cannot cause a NULL dereference.

Detected by static analysis and reviewed with AI-assisted source auditing.

Fixes: 080bbd19c9dd ("octeontx2-af: cn10k: mcs: Add mailboxes for port related operations")
Assisted-by: LLM
Signed-off-by: Slavin Liu <bolin.liu@seu.edu.cn>
---
 drivers/net/ethernet/marvell/octeontx2/af/mcs_rvu_if.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/mcs_rvu_if.c b/drivers/net/ethernet/marvell/octeontx2/af/mcs_rvu_if.c
index fce22e314cac..0ee2d0d698e5 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/mcs_rvu_if.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/mcs_rvu_if.c
@@ -889,6 +889,11 @@ int rvu_mcs_init(struct rvu *rvu)
 		rvu_mcs_set_lmac_bmap(rvu);
 	}
 
+	for (mcs_id = 0; mcs_id < rvu->mcs_blk_cnt; mcs_id++) {
+		if (!mcs_get_pdata(mcs_id))
+			return -ENODEV;
+	}
+
 	/* Install default tcam bypass entry and set port to operational mode */
 	for (mcs_id = 0; mcs_id < rvu->mcs_blk_cnt; mcs_id++) {
 		mcs = mcs_get_pdata(mcs_id);

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-09-13 12:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-13 12:52 [PATCH net] octeontx2-af: validate MCS blocks before initialization Slavin Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox