]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
octeontx2-af: npc: cn20k: Initialize default-rule index outputs up front
authorRatheesh Kannoth <rkannoth@marvell.com>
Wed, 29 Apr 2026 02:27:20 +0000 (07:57 +0530)
committerJakub Kicinski <kuba@kernel.org>
Fri, 1 May 2026 01:50:17 +0000 (18:50 -0700)
npc_cn20k_dft_rules_idx_get() wrote USHRT_MAX into individual outputs only
on some error paths (lbk promisc lookup, VF ucast lookup, and the PF rule
walk), which could leave other caller slots stale across retries.

Set every non-NULL bcast/mcast/promisc/ucast pointer to USHRT_MAX once at
entry, then drop the duplicate assignments on failure. Successful lookups
still overwrite the relevant slot before returning.

Fixes: 09d3b7a1403f ("octeontx2-af: npc: cn20k: Allocate default MCAM indexes")
Signed-off-by: Ratheesh Kannoth <rkannoth@marvell.com>
Link: https://patch.msgid.link/20260429022722.1110289-9-rkannoth@marvell.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c

index bb0a9ac7aab3ba5cc8ad20d7191d6b7443b84350..b3f34b84c1149930b6e7d5db6ecbc0279d941c0c 100644 (file)
@@ -4016,6 +4016,13 @@ int npc_cn20k_dft_rules_idx_get(struct rvu *rvu, u16 pcifunc, u16 *bcast,
        void *val;
        int i, j;
 
+       for (i = 0; i < ARRAY_SIZE(ptr); i++) {
+               if (!ptr[i])
+                       continue;
+
+               *ptr[i] = USHRT_MAX;
+       }
+
        if (!npc_priv.init_done)
                return 0;
 
@@ -4031,7 +4038,6 @@ int npc_cn20k_dft_rules_idx_get(struct rvu *rvu, u16 pcifunc, u16 *bcast,
                                 npc_dft_rule_name[NPC_DFT_RULE_PROMISC_ID],
                                 pcifunc);
 
-                       *ptr[0] = USHRT_MAX;
                        return -ESRCH;
                }
 
@@ -4051,7 +4057,6 @@ int npc_cn20k_dft_rules_idx_get(struct rvu *rvu, u16 pcifunc, u16 *bcast,
                                 npc_dft_rule_name[NPC_DFT_RULE_UCAST_ID],
                                 pcifunc);
 
-                       *ptr[3] = USHRT_MAX;
                        return -ESRCH;
                }
 
@@ -4071,7 +4076,6 @@ int npc_cn20k_dft_rules_idx_get(struct rvu *rvu, u16 pcifunc, u16 *bcast,
                                 __func__,
                                 npc_dft_rule_name[i], pcifunc);
 
-                       *ptr[j] = USHRT_MAX;
                        continue;
                }