Subject: [bug report] octeontx2-af: npc: cn20k: virtual index support

From: Dan Carpenter <[email-masked]>
Date: Fri, 10 Apr 2026 13:12:52 +0300

Hello Ratheesh Kannoth,

Commit 645c6e3c1999 ("octeontx2-af: npc: cn20k: virtual index
support") from Feb 24, 2026 (linux-next), leads to the following
Smatch static checker warning:

	drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c:3534 npc_defrag_alloc_free_slots()
	warn: missing error code 'rc'

drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c
    3479 static int npc_defrag_alloc_free_slots(struct rvu *rvu,
    3480                                        struct npc_defrag_node *f,
    3481                                        int cnt, u16 *save)
    3482 {
    3483         int alloc_cnt1, alloc_cnt2;
    3484         struct npc_subbank *sb;
    3485         int rc, sb_off, i;
    3486         bool deleted;
    3487 
    3488         sb = &npc_priv.sb[f->idx];
    3489 
    3490         alloc_cnt1 = 0;
    3491         alloc_cnt2 = 0;
    3492 
    3493         rc = __npc_subbank_alloc(rvu, sb,
    3494                                  NPC_MCAM_KEY_X2, sb->b0b,
    3495                                  sb->b0t,
    3496                                  NPC_MCAM_LOWER_PRIO,
    3497                                  false, cnt, save, cnt, true,
    3498                                  &alloc_cnt1);
    3499         if (alloc_cnt1 < cnt) {
    3500                 rc = __npc_subbank_alloc(rvu, sb,
    3501                                          NPC_MCAM_KEY_X2, sb->b1b,
    3502                                          sb->b1t,
    3503                                          NPC_MCAM_LOWER_PRIO,
    3504                                          false, cnt - alloc_cnt1,
    3505                                          save + alloc_cnt1,
    3506                                          cnt - alloc_cnt1,
    3507                                          true, &alloc_cnt2);
    3508         }
    3509 
    3510         if (alloc_cnt1 + alloc_cnt2 != cnt) {
    3511                 dev_err(rvu->dev,
    3512                         "%s: Failed to alloc cnt=%u alloc_cnt1=%u alloc_cnt2=%u\n",
    3513                         __func__, cnt, alloc_cnt1, alloc_cnt2);
    3514                 goto fail_free_alloc;
    3515         }
    3516         return 0;
    3517 
    3518 fail_free_alloc:
    3519         for (i = 0; i < alloc_cnt1 + alloc_cnt2; i++) {
    3520                 rc =  npc_mcam_idx_2_subbank_idx(rvu, save[i],
    3521                                                  &sb, &sb_off);
    3522                 if (rc) {
    3523                         dev_err(rvu->dev,
    3524                                 "%s: Error to find subbank for mcam idx=%u\n",
    3525                                 __func__, save[i]);
    3526                         break;
    3527                 }
    3528 
    3529                 deleted = __npc_subbank_free(rvu, sb, sb_off);
    3530                 if (!deleted) {
    3531                         dev_err(rvu->dev,
    3532                                 "%s: Error to free mcam idx=%u\n",
    3533                                 __func__, save[i]);
--> 3534                         break;

Set an error code here?

    3535                 }
    3536         }
    3537 
    3538         return rc;
    3539 }

This email is a free service from the Smatch-CI project [smatch.sf.net].

regards,
dan carpenter