diff mbox series

[net-next] octeontx2-af: Fixes static warnings

Message ID 20220714042843.250537-1-rkannoth@marvell.com (mailing list archive)
State Accepted
Commit da92e03c7fbf4dc6e1a4a030433c8c30946e6aa0
Delegated to: Netdev Maintainers
Headers show
Series [net-next] octeontx2-af: Fixes static warnings | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 5 maintainers not CCed: hkelam@marvell.com sbhatta@marvell.com lcherian@marvell.com gakula@marvell.com jerinj@marvell.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch warning WARNING: line length of 82 exceeds 80 columns WARNING: line length of 84 exceeds 80 columns WARNING: line length of 86 exceeds 80 columns WARNING: line length of 92 exceeds 80 columns WARNING: line length of 96 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Ratheesh Kannoth July 14, 2022, 4:28 a.m. UTC
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 <rkannoth@marvell.com>
---
 .../marvell/octeontx2/af/rvu_npc_hash.c       | 49 ++++++++++++++-----
 .../marvell/octeontx2/nic/otx2_dmac_flt.c     | 21 ++++++--
 2 files changed, 55 insertions(+), 15 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org July 15, 2022, 11:10 a.m. UTC | #1
Hello:

This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

On Thu, 14 Jul 2022 09:58:43 +0530 you wrote:
> 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'.
> 
> [...]

Here is the summary with links:
  - [net-next] octeontx2-af: Fixes static warnings
    https://git.kernel.org/netdev/net-next/c/da92e03c7fbf

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c
index 1195b690f483..594029007f85 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c
@@ -1199,8 +1199,9 @@  static int rvu_npc_exact_del_table_entry_by_id(struct rvu *rvu, u32 seq_id)
 	struct npc_exact_table_entry *entry = NULL;
 	struct npc_exact_table *table;
 	bool disable_cam = false;
-	u32 drop_mcam_idx;
+	u32 drop_mcam_idx = -1;
 	int *cnt;
+	bool rc;
 
 	table = rvu->hw->table;
 
@@ -1209,7 +1210,7 @@  static int rvu_npc_exact_del_table_entry_by_id(struct rvu *rvu, u32 seq_id)
 	/* Lookup for entry which needs to be updated */
 	entry = __rvu_npc_exact_find_entry_by_seq_id(rvu, seq_id);
 	if (!entry) {
-		dev_dbg(rvu->dev, "%s: failed to find entry for id=0x%x\n", __func__, seq_id);
+		dev_dbg(rvu->dev, "%s: failed to find entry for id=%d\n", __func__, seq_id);
 		mutex_unlock(&table->lock);
 		return -ENODATA;
 	}
@@ -1223,8 +1224,14 @@  static int rvu_npc_exact_del_table_entry_by_id(struct rvu *rvu, u32 seq_id)
 
 	(*cnt)--;
 
-	rvu_npc_exact_get_drop_rule_info(rvu, NIX_INTF_TYPE_CGX, entry->cgx_id, entry->lmac_id,
-					 &drop_mcam_idx, NULL, NULL, NULL);
+	rc = rvu_npc_exact_get_drop_rule_info(rvu, NIX_INTF_TYPE_CGX, entry->cgx_id,
+					      entry->lmac_id, &drop_mcam_idx, NULL, NULL, NULL);
+	if (!rc) {
+		dev_dbg(rvu->dev, "%s: failed to retrieve drop info for id=0x%x\n",
+			__func__, seq_id);
+		mutex_unlock(&table->lock);
+		return -ENODATA;
+	}
 
 	if (entry->cmd)
 		__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,
 	u32 drop_mcam_idx;
 	u32 index;
 	u64 mdata;
+	bool rc;
 	int err;
 	u8 ways;
 
@@ -1304,8 +1312,15 @@  static int rvu_npc_exact_add_table_entry(struct rvu *rvu, u8 cgx_id, u8 lmac_id,
 		return err;
 	}
 
-	rvu_npc_exact_get_drop_rule_info(rvu, NIX_INTF_TYPE_CGX, cgx_id, lmac_id,
-					 &drop_mcam_idx, NULL, NULL, NULL);
+	rc = rvu_npc_exact_get_drop_rule_info(rvu, NIX_INTF_TYPE_CGX, cgx_id, lmac_id,
+					      &drop_mcam_idx, NULL, NULL, NULL);
+	if (!rc) {
+		rvu_npc_exact_dealloc_table_entry(rvu, opc_type, ways, index);
+		dev_dbg(rvu->dev, "%s: failed to get drop rule info cgx=%d lmac=%d\n",
+			__func__, cgx_id, lmac_id);
+		return -EINVAL;
+	}
+
 	if (cmd)
 		__rvu_npc_exact_cmd_rules_cnt_update(rvu, drop_mcam_idx, 1, &enable_cam);
 
@@ -1388,7 +1403,7 @@  static int rvu_npc_exact_update_table_entry(struct rvu *rvu, u8 cgx_id, u8 lmac_
 
 	dev_dbg(rvu->dev,
 		"%s: Successfully updated entry (index=%d, dmac=%pM, ways=%d opc_type=%d\n",
-		__func__, hash_index, entry->mac, entry->ways, entry->opc_type);
+		__func__, entry->index, entry->mac, entry->ways, entry->opc_type);
 
 	dev_dbg(rvu->dev, "%s: Successfully updated entry (old mac=%pM new_mac=%pM\n",
 		__func__, old_mac, new_mac);
@@ -1414,13 +1429,19 @@  int rvu_npc_exact_promisc_disable(struct rvu *rvu, u16 pcifunc)
 	u8 cgx_id, lmac_id;
 	u32 drop_mcam_idx;
 	bool *promisc;
+	bool rc;
 	u32 cnt;
 
 	table = rvu->hw->table;
 
 	rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id);
-	rvu_npc_exact_get_drop_rule_info(rvu, NIX_INTF_TYPE_CGX, cgx_id, lmac_id,
-					 &drop_mcam_idx, NULL, NULL, NULL);
+	rc = rvu_npc_exact_get_drop_rule_info(rvu, NIX_INTF_TYPE_CGX, cgx_id, lmac_id,
+					      &drop_mcam_idx, NULL, NULL, NULL);
+	if (!rc) {
+		dev_dbg(rvu->dev, "%s: failed to get drop rule info cgx=%d lmac=%d\n",
+			__func__, cgx_id, lmac_id);
+		return -EINVAL;
+	}
 
 	mutex_lock(&table->lock);
 	promisc = &table->promisc_mode[drop_mcam_idx];
@@ -1459,13 +1480,19 @@  int rvu_npc_exact_promisc_enable(struct rvu *rvu, u16 pcifunc)
 	u8 cgx_id, lmac_id;
 	u32 drop_mcam_idx;
 	bool *promisc;
+	bool rc;
 	u32 cnt;
 
 	table = rvu->hw->table;
 
 	rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id);
-	rvu_npc_exact_get_drop_rule_info(rvu, NIX_INTF_TYPE_CGX, cgx_id, lmac_id,
-					 &drop_mcam_idx, NULL, NULL, NULL);
+	rc = rvu_npc_exact_get_drop_rule_info(rvu, NIX_INTF_TYPE_CGX, cgx_id, lmac_id,
+					      &drop_mcam_idx, NULL, NULL, NULL);
+	if (!rc) {
+		dev_dbg(rvu->dev, "%s: failed to get drop rule info cgx=%d lmac=%d\n",
+			__func__, cgx_id, lmac_id);
+		return -EINVAL;
+	}
 
 	mutex_lock(&table->lock);
 	promisc = &table->promisc_mode[drop_mcam_idx];
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_dmac_flt.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_dmac_flt.c
index 846a0294a215..80d853b343f9 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_dmac_flt.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_dmac_flt.c
@@ -54,12 +54,19 @@  static int otx2_dmacflt_add_pfmac(struct otx2_nic *pf, u32 *dmac_index)
 	ether_addr_copy(req->mac_addr, pf->netdev->dev_addr);
 	err = otx2_sync_mbox_msg(&pf->mbox);
 
-	if (!err) {
-		rsp = (struct cgx_mac_addr_set_or_get *)
-			 otx2_mbox_get_rsp(&pf->mbox.mbox, 0, &req->hdr);
-		*dmac_index = rsp->index;
+	if (err)
+		goto out;
+
+	rsp = (struct cgx_mac_addr_set_or_get *)
+		otx2_mbox_get_rsp(&pf->mbox.mbox, 0, &req->hdr);
+
+	if (IS_ERR_OR_NULL(rsp)) {
+		err = -EINVAL;
+		goto out;
 	}
 
+	*dmac_index = rsp->index;
+out:
 	mutex_unlock(&pf->mbox.lock);
 	return err;
 }
@@ -154,6 +161,12 @@  int otx2_dmacflt_get_max_cnt(struct otx2_nic *pf)
 
 	rsp = (struct cgx_max_dmac_entries_get_rsp *)
 		     otx2_mbox_get_rsp(&pf->mbox.mbox, 0, &msg->hdr);
+
+	if (IS_ERR_OR_NULL(rsp)) {
+		err = -EINVAL;
+		goto out;
+	}
+
 	pf->flow_cfg->dmacflt_max_flows = rsp->max_dmac_filters;
 
 out: