Thread (4 messages) flat view 4 messages, 4 authors, 6d ago

RE: [EXTERNAL] [PATCH net] octeontx2-af: validate MCS blocks before initialization

From: Geethasowjanya Akula <gakula@marvell.com>
Date: 2026-09-16 06:50:15
Also in: lkml

quoted hunk ↗ jump to hunk
-----Original Message-----
From: Slavin Liu <redacted>
Sent: Sunday, September 13, 2026 6:22 PM
To: Sunil Kovvuri Goutham <sgoutham@marvell.com>; Ratheesh Kannoth
[off-list ref]; Geethasowjanya Akula [off-list ref];
Subbaraya Sundeep Bhatta [off-list ref];
andrew+netdev@lunn.ch; davem@davemloft.net; edumazet@google.com;
kuba@kernel.org; pabeni@redhat.com
Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org;
bolin.liu@seu.edu.cn
Subject: [EXTERNAL] [PATCH net] octeontx2-af: validate MCS blocks before
initialization
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 <redacted>
---
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);
Thanks, Slavin, for the patch.
The additional check can be moved into the existing loop below, which avoids iterating over the MCS blocks twice.

Also, on CN10KB silicon, the MCS block count is always 1. Therefore, the existing check: "if (!rvu->mcs_blk_cnt)" 
should be sufficient to handle the absence of MCS blocks.
          
@@ -892,6 +892,8 @@ int rvu_mcs_init(struct rvu *rvu)
        /* 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);
+               if (!mcs_get_pdata(mcs_id))
+                       return -ENODEV
                mcs_install_flowid_bypass_entry(mcs);

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help