All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: rkannoth@marvell.com
Cc: kernel-janitors@vger.kernel.org
Subject: [bug report] octeontx2-af: Drop rules for NPC MCAM
Date: Wed, 13 Jul 2022 14:27:36 +0300	[thread overview]
Message-ID: <Ys6sKMjAtcMMloTI@kili> (raw)

Hello Ratheesh Kannoth,

The patch 3571fe07a090: "octeontx2-af: Drop rules for NPC MCAM" from
Jul 8, 2022, leads to the following Smatch static checker warning:

	drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c:1232 rvu_npc_exact_del_table_entry_by_id()
	error: uninitialized symbol 'drop_mcam_idx'.

drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c
    1199 static int rvu_npc_exact_del_table_entry_by_id(struct rvu *rvu, u32 seq_id)
    1200 {
    1201         struct npc_exact_table_entry *entry = NULL;
    1202         struct npc_exact_table *table;
    1203         bool disable_cam = false;
    1204         u32 drop_mcam_idx;
    1205         int *cnt;
    1206 
    1207         table = rvu->hw->table;
    1208 
    1209         mutex_lock(&table->lock);
    1210 
    1211         /* Lookup for entry which needs to be updated */
    1212         entry = __rvu_npc_exact_find_entry_by_seq_id(rvu, seq_id);
    1213         if (!entry) {
    1214                 dev_dbg(rvu->dev, "%s: failed to find entry for id=0x%x\n", __func__, seq_id);
    1215                 mutex_unlock(&table->lock);
    1216                 return -ENODATA;
    1217         }
    1218 
    1219         cnt = (entry->opc_type == NPC_EXACT_OPC_CAM) ? &table->cam_tbl_entry_cnt :
    1220                                 &table->mem_tbl_entry_cnt;
    1221 
    1222         /* delete from lists */
    1223         list_del_init(&entry->list);
    1224         list_del_init(&entry->glist);
    1225 
    1226         (*cnt)--;
    1227 
    1228         rvu_npc_exact_get_drop_rule_info(rvu, NIX_INTF_TYPE_CGX, entry->cgx_id, entry->lmac_id,
    1229                                          &drop_mcam_idx, NULL, NULL, NULL);

No checks for errors

    1230 
    1231         if (entry->cmd)
--> 1232                 __rvu_npc_exact_cmd_rules_cnt_update(rvu, drop_mcam_idx, -1, &disable_cam);

Uninitialized value leads to out of bounds access

    1233 
    1234         /* No dmac filter rules; disable drop on hit rule */
    1235         if (disable_cam) {
    1236                 rvu_npc_enable_mcam_by_entry_index(rvu, drop_mcam_idx, NIX_INTF_RX, false);
    1237                 dev_dbg(rvu->dev, "%s: Disabling mcam idx %d\n",
    1238                         __func__, drop_mcam_idx);
    1239         }
    1240 
    1241         mutex_unlock(&table->lock);
    1242 
    1243         rvu_npc_exact_dealloc_table_entry(rvu, entry->opc_type, entry->ways, entry->index);
    1244 
    1245         rvu_npc_exact_free_id(rvu, seq_id);
    1246 
    1247         dev_dbg(rvu->dev, "%s: delete entry success for id=0x%x, mca=%pM\n",
    1248                 __func__, seq_id, entry->mac);
    1249         kfree(entry);
    1250 
    1251         return 0;
    1252 }

regards,
dan carpenter

             reply	other threads:[~2022-07-13 11:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-13 11:27 Dan Carpenter [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-07-13 11:32 [bug report] octeontx2-af: Drop rules for NPC MCAM Dan Carpenter
2024-10-07  6:26 Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Ys6sKMjAtcMMloTI@kili \
    --to=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=rkannoth@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.