Skip to content

Commit da92e03

Browse files
rkannoth1davem330
authored andcommitted
octeontx2-af: Fixes static warnings
Fixes smatch static tool warning reported by smatch tool. rvu_npc_hash.c:1232 rvu_npc_exact_del_table_entry_by_id() error: uninitialized symbol 'drop_mcam_idx'. rvu_npc_hash.c:1312 rvu_npc_exact_add_table_entry() error: uninitialized symbol 'drop_mcam_idx'. rvu_npc_hash.c:1391 rvu_npc_exact_update_table_entry() error: uninitialized symbol 'hash_index'. rvu_npc_hash.c:1428 rvu_npc_exact_promisc_disable() error: uninitialized symbol 'drop_mcam_idx'. rvu_npc_hash.c:1473 rvu_npc_exact_promisc_enable() error: uninitialized symbol 'drop_mcam_idx'. otx2_dmac_flt.c:191 otx2_dmacflt_update() error: 'rsp' dereferencing possible ERR_PTR() otx2_dmac_flt.c:60 otx2_dmacflt_add_pfmac() error: 'rsp' dereferencing possible ERR_PTR() Signed-off-by: Ratheesh Kannoth <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4bbaf76 commit da92e03

File tree

2 files changed

+55
-15
lines changed

2 files changed

+55
-15
lines changed

drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,8 +1199,9 @@ static int rvu_npc_exact_del_table_entry_by_id(struct rvu *rvu, u32 seq_id)
11991199
struct npc_exact_table_entry *entry = NULL;
12001200
struct npc_exact_table *table;
12011201
bool disable_cam = false;
1202-
u32 drop_mcam_idx;
1202+
u32 drop_mcam_idx = -1;
12031203
int *cnt;
1204+
bool rc;
12041205

12051206
table = rvu->hw->table;
12061207

@@ -1209,7 +1210,7 @@ static int rvu_npc_exact_del_table_entry_by_id(struct rvu *rvu, u32 seq_id)
12091210
/* Lookup for entry which needs to be updated */
12101211
entry = __rvu_npc_exact_find_entry_by_seq_id(rvu, seq_id);
12111212
if (!entry) {
1212-
dev_dbg(rvu->dev, "%s: failed to find entry for id=0x%x\n", __func__, seq_id);
1213+
dev_dbg(rvu->dev, "%s: failed to find entry for id=%d\n", __func__, seq_id);
12131214
mutex_unlock(&table->lock);
12141215
return -ENODATA;
12151216
}
@@ -1223,8 +1224,14 @@ static int rvu_npc_exact_del_table_entry_by_id(struct rvu *rvu, u32 seq_id)
12231224

12241225
(*cnt)--;
12251226

1226-
rvu_npc_exact_get_drop_rule_info(rvu, NIX_INTF_TYPE_CGX, entry->cgx_id, entry->lmac_id,
1227-
&drop_mcam_idx, NULL, NULL, NULL);
1227+
rc = rvu_npc_exact_get_drop_rule_info(rvu, NIX_INTF_TYPE_CGX, entry->cgx_id,
1228+
entry->lmac_id, &drop_mcam_idx, NULL, NULL, NULL);
1229+
if (!rc) {
1230+
dev_dbg(rvu->dev, "%s: failed to retrieve drop info for id=0x%x\n",
1231+
__func__, seq_id);
1232+
mutex_unlock(&table->lock);
1233+
return -ENODATA;
1234+
}
12281235

12291236
if (entry->cmd)
12301237
__rvu_npc_exact_cmd_rules_cnt_update(rvu, drop_mcam_idx, -1, &disable_cam);
@@ -1276,6 +1283,7 @@ static int rvu_npc_exact_add_table_entry(struct rvu *rvu, u8 cgx_id, u8 lmac_id,
12761283
u32 drop_mcam_idx;
12771284
u32 index;
12781285
u64 mdata;
1286+
bool rc;
12791287
int err;
12801288
u8 ways;
12811289

@@ -1304,8 +1312,15 @@ static int rvu_npc_exact_add_table_entry(struct rvu *rvu, u8 cgx_id, u8 lmac_id,
13041312
return err;
13051313
}
13061314

1307-
rvu_npc_exact_get_drop_rule_info(rvu, NIX_INTF_TYPE_CGX, cgx_id, lmac_id,
1308-
&drop_mcam_idx, NULL, NULL, NULL);
1315+
rc = rvu_npc_exact_get_drop_rule_info(rvu, NIX_INTF_TYPE_CGX, cgx_id, lmac_id,
1316+
&drop_mcam_idx, NULL, NULL, NULL);
1317+
if (!rc) {
1318+
rvu_npc_exact_dealloc_table_entry(rvu, opc_type, ways, index);
1319+
dev_dbg(rvu->dev, "%s: failed to get drop rule info cgx=%d lmac=%d\n",
1320+
__func__, cgx_id, lmac_id);
1321+
return -EINVAL;
1322+
}
1323+
13091324
if (cmd)
13101325
__rvu_npc_exact_cmd_rules_cnt_update(rvu, drop_mcam_idx, 1, &enable_cam);
13111326

@@ -1388,7 +1403,7 @@ static int rvu_npc_exact_update_table_entry(struct rvu *rvu, u8 cgx_id, u8 lmac_
13881403

13891404
dev_dbg(rvu->dev,
13901405
"%s: Successfully updated entry (index=%d, dmac=%pM, ways=%d opc_type=%d\n",
1391-
__func__, hash_index, entry->mac, entry->ways, entry->opc_type);
1406+
__func__, entry->index, entry->mac, entry->ways, entry->opc_type);
13921407

13931408
dev_dbg(rvu->dev, "%s: Successfully updated entry (old mac=%pM new_mac=%pM\n",
13941409
__func__, old_mac, new_mac);
@@ -1414,13 +1429,19 @@ int rvu_npc_exact_promisc_disable(struct rvu *rvu, u16 pcifunc)
14141429
u8 cgx_id, lmac_id;
14151430
u32 drop_mcam_idx;
14161431
bool *promisc;
1432+
bool rc;
14171433
u32 cnt;
14181434

14191435
table = rvu->hw->table;
14201436

14211437
rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id);
1422-
rvu_npc_exact_get_drop_rule_info(rvu, NIX_INTF_TYPE_CGX, cgx_id, lmac_id,
1423-
&drop_mcam_idx, NULL, NULL, NULL);
1438+
rc = rvu_npc_exact_get_drop_rule_info(rvu, NIX_INTF_TYPE_CGX, cgx_id, lmac_id,
1439+
&drop_mcam_idx, NULL, NULL, NULL);
1440+
if (!rc) {
1441+
dev_dbg(rvu->dev, "%s: failed to get drop rule info cgx=%d lmac=%d\n",
1442+
__func__, cgx_id, lmac_id);
1443+
return -EINVAL;
1444+
}
14241445

14251446
mutex_lock(&table->lock);
14261447
promisc = &table->promisc_mode[drop_mcam_idx];
@@ -1459,13 +1480,19 @@ int rvu_npc_exact_promisc_enable(struct rvu *rvu, u16 pcifunc)
14591480
u8 cgx_id, lmac_id;
14601481
u32 drop_mcam_idx;
14611482
bool *promisc;
1483+
bool rc;
14621484
u32 cnt;
14631485

14641486
table = rvu->hw->table;
14651487

14661488
rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id);
1467-
rvu_npc_exact_get_drop_rule_info(rvu, NIX_INTF_TYPE_CGX, cgx_id, lmac_id,
1468-
&drop_mcam_idx, NULL, NULL, NULL);
1489+
rc = rvu_npc_exact_get_drop_rule_info(rvu, NIX_INTF_TYPE_CGX, cgx_id, lmac_id,
1490+
&drop_mcam_idx, NULL, NULL, NULL);
1491+
if (!rc) {
1492+
dev_dbg(rvu->dev, "%s: failed to get drop rule info cgx=%d lmac=%d\n",
1493+
__func__, cgx_id, lmac_id);
1494+
return -EINVAL;
1495+
}
14691496

14701497
mutex_lock(&table->lock);
14711498
promisc = &table->promisc_mode[drop_mcam_idx];

drivers/net/ethernet/marvell/octeontx2/nic/otx2_dmac_flt.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,19 @@ static int otx2_dmacflt_add_pfmac(struct otx2_nic *pf, u32 *dmac_index)
5454
ether_addr_copy(req->mac_addr, pf->netdev->dev_addr);
5555
err = otx2_sync_mbox_msg(&pf->mbox);
5656

57-
if (!err) {
58-
rsp = (struct cgx_mac_addr_set_or_get *)
59-
otx2_mbox_get_rsp(&pf->mbox.mbox, 0, &req->hdr);
60-
*dmac_index = rsp->index;
57+
if (err)
58+
goto out;
59+
60+
rsp = (struct cgx_mac_addr_set_or_get *)
61+
otx2_mbox_get_rsp(&pf->mbox.mbox, 0, &req->hdr);
62+
63+
if (IS_ERR_OR_NULL(rsp)) {
64+
err = -EINVAL;
65+
goto out;
6166
}
6267

68+
*dmac_index = rsp->index;
69+
out:
6370
mutex_unlock(&pf->mbox.lock);
6471
return err;
6572
}
@@ -154,6 +161,12 @@ int otx2_dmacflt_get_max_cnt(struct otx2_nic *pf)
154161

155162
rsp = (struct cgx_max_dmac_entries_get_rsp *)
156163
otx2_mbox_get_rsp(&pf->mbox.mbox, 0, &msg->hdr);
164+
165+
if (IS_ERR_OR_NULL(rsp)) {
166+
err = -EINVAL;
167+
goto out;
168+
}
169+
157170
pf->flow_cfg->dmacflt_max_flows = rsp->max_dmac_filters;
158171

159172
out:

0 commit comments

Comments
 (0)