net/cpfl: fix coverity issue 403269, 403270 and 403272

Message ID 20231019092418.1477689-1-wenjing.qiao@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Qi Zhang
Headers
Series net/cpfl: fix coverity issue 403269, 403270 and 403272 |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/github-robot: build success github build: passed
ci/Intel-compilation success Compilation OK
ci/intel-Functional success Functional PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/intel-Testing success Testing PASS

Commit Message

Wenjing Qiao Oct. 19, 2023, 9:24 a.m. UTC
  From: Wenjing Qiao <wenjing.qiao@intel.com>

Fix logically dead code and dereference before null check
issues reported in coverity scan.

Coverity issue: 403269
Coverity issue: 403270
Coverity issue: 403272
Fixes: 41f20298ee8c ("net/cpfl: parse flow offloading hint from JSON")
Fixes: 6cc97c9971d7 ("net/cpfl: build action mapping rules from JSON")

Signed-off-by: Wenjing Qiao <wenjing.qiao@intel.com>
---
 drivers/net/cpfl/cpfl_ethdev.h      | 3 +--
 drivers/net/cpfl/cpfl_flow_parser.c | 4 ----
 2 files changed, 1 insertion(+), 6 deletions(-)
  

Comments

Qi Zhang Oct. 20, 2023, 12:43 a.m. UTC | #1
> -----Original Message-----
> From: Qiao, Wenjing <wenjing.qiao@intel.com>
> Sent: Thursday, October 19, 2023 5:24 PM
> To: Wu, Jingjing <jingjing.wu@intel.com>; Xing, Beilei <beilei.xing@intel.com>
> Cc: dev@dpdk.org; Zhang, Qi Z <qi.z.zhang@intel.com>; Qiao, Wenjing
> <wenjing.qiao@intel.com>
> Subject: [PATCH] net/cpfl: fix coverity issue 403269, 403270 and 403272
> 
> From: Wenjing Qiao <wenjing.qiao@intel.com>
> 
> Fix logically dead code and dereference before null check issues reported in
> coverity scan.
> 
> Coverity issue: 403269
> Coverity issue: 403270
> Coverity issue: 403272
> Fixes: 41f20298ee8c ("net/cpfl: parse flow offloading hint from JSON")
> Fixes: 6cc97c9971d7 ("net/cpfl: build action mapping rules from JSON")
> 
> Signed-off-by: Wenjing Qiao <wenjing.qiao@intel.com>

Acked-by: Qi Zhang <qi.z.zhang@intel.com>

Applied to dpdk-next-net-intel.

Thanks
Qi
  

Patch

diff --git a/drivers/net/cpfl/cpfl_ethdev.h b/drivers/net/cpfl/cpfl_ethdev.h
index efb0eb5251..6f5af4f7f3 100644
--- a/drivers/net/cpfl/cpfl_ethdev.h
+++ b/drivers/net/cpfl/cpfl_ethdev.h
@@ -280,7 +280,6 @@  cpfl_get_port_id(struct cpfl_itf *itf)
 static inline uint16_t
 cpfl_get_vsi_id(struct cpfl_itf *itf)
 {
-	struct cpfl_adapter_ext *adapter = itf->adapter;
 	struct cpfl_vport_info *info;
 	uint32_t vport_id;
 	int ret;
@@ -301,7 +300,7 @@  cpfl_get_vsi_id(struct cpfl_itf *itf)
 		vport_identity.pf_id = CPFL_ACC_CPF_ID;
 		vport_identity.vf_id = 0;
 		vport_identity.vport_id = vport_id;
-		ret = rte_hash_lookup_data(adapter->vport_map_hash,
+		ret = rte_hash_lookup_data(itf->adapter->vport_map_hash,
 					   &vport_identity,
 					   (void **)&info);
 		if (ret < 0) {
diff --git a/drivers/net/cpfl/cpfl_flow_parser.c b/drivers/net/cpfl/cpfl_flow_parser.c
index 0e623494a2..412f7feed0 100644
--- a/drivers/net/cpfl/cpfl_flow_parser.c
+++ b/drivers/net/cpfl/cpfl_flow_parser.c
@@ -844,8 +844,6 @@  cpfl_parser_destroy(struct cpfl_flow_js_parser *parser)
 	for (i = 0; i < parser->pr_size; i++) {
 		struct cpfl_flow_js_pr *pattern = &parser->patterns[i];
 
-		if (!pattern)
-			continue;
 		for (j = 0; j < pattern->key.proto_size; j++)
 			rte_free(pattern->key.protocols[j].fields);
 		rte_free(pattern->key.protocols);
@@ -863,8 +861,6 @@  cpfl_parser_destroy(struct cpfl_flow_js_parser *parser)
 	for (i = 0; i < parser->mr_size; i++) {
 		struct cpfl_flow_js_mr *mr = &parser->modifications[i];
 
-		if (!mr)
-			continue;
 		rte_free(mr->key.actions);
 		rte_free(mr->action.mod.layout);
 	}