octeontx2-af: Drop rules for NPC MCAM
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