DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] remove unnecessary null check before free/rte_free
@ 2023-10-24 22:58 Stephen Hemminger
  2023-11-06 15:46 ` Thomas Monjalon
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Hemminger @ 2023-10-24 22:58 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, Akhil Goyal, Fan Zhang, Konstantin Ananyev,
	Ajit Khaparde, Somnath Kotur, Yuying Zhang, Beilei Xing,
	Chaoyong He, Devendra Singh Rawat, Alok Prasad

This is the latest round of places that are checking for NULL
pointer before calling free or rte_free. It is result of applying
the nullfree.cocci script.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/test/test_cryptodev_asym.c   | 3 +--
 app/test/test_reassembly_perf.c  | 3 +--
 drivers/net/bnxt/bnxt_ethdev.c   | 3 +--
 drivers/net/bnxt/bnxt_vnic.c     | 3 +--
 drivers/net/cpfl/cpfl_fxp_rule.c | 3 +--
 drivers/net/nfp/nfp_ipsec.c      | 3 +--
 drivers/net/qede/base/bcm_osal.c | 3 +--
 7 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/app/test/test_cryptodev_asym.c b/app/test/test_cryptodev_asym.c
index 94bb091df352..cc06a4de027c 100644
--- a/app/test/test_cryptodev_asym.c
+++ b/app/test/test_cryptodev_asym.c
@@ -565,8 +565,7 @@ ut_teardown_asym(void)
 
 	if (self->sess != NULL)
 		rte_cryptodev_asym_session_free(dev_id, self->sess);
-	if (self->op != NULL)
-		rte_crypto_op_free(self->op);
+	rte_crypto_op_free(self->op);
 	self->sess = NULL;
 	self->op = NULL;
 	self->result_op = NULL;
diff --git a/app/test/test_reassembly_perf.c b/app/test/test_reassembly_perf.c
index 4b4929d77798..3912179022fc 100644
--- a/app/test/test_reassembly_perf.c
+++ b/app/test/test_reassembly_perf.c
@@ -81,8 +81,7 @@ reassembly_test_teardown(void)
 	if (frag_tbl != NULL)
 		rte_ip_frag_table_destroy(frag_tbl);
 
-	if (pkt_pool != NULL)
-		rte_mempool_free(pkt_pool);
+	rte_mempool_free(pkt_pool);
 }
 
 static void
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 5c4d96d4b14a..acf7e6e46e23 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -6004,8 +6004,7 @@ static void bnxt_free_ctx_mem_buf(struct bnxt_ctx_mem_buf_info *ctx)
 	if (!ctx)
 		return;
 
-	if (ctx->va)
-		rte_free(ctx->va);
+	rte_free(ctx->va);
 
 	ctx->va = NULL;
 	ctx->dma = RTE_BAD_IOVA;
diff --git a/drivers/net/bnxt/bnxt_vnic.c b/drivers/net/bnxt/bnxt_vnic.c
index 2be456956ddc..f86d27fd7965 100644
--- a/drivers/net/bnxt/bnxt_vnic.c
+++ b/drivers/net/bnxt/bnxt_vnic.c
@@ -847,8 +847,7 @@ bnxt_vnic_rss_hash_algo_update(struct bnxt *bp,
 
 int32_t bnxt_vnic_queue_db_deinit(struct bnxt *bp)
 {
-	if (bp->vnic_queue_db.rss_q_db != NULL)
-		rte_hash_free(bp->vnic_queue_db.rss_q_db);
+	rte_hash_free(bp->vnic_queue_db.rss_q_db);
 	return 0;
 }
 
diff --git a/drivers/net/cpfl/cpfl_fxp_rule.c b/drivers/net/cpfl/cpfl_fxp_rule.c
index ea65e205072a..b6e4ac29e2c7 100644
--- a/drivers/net/cpfl/cpfl_fxp_rule.c
+++ b/drivers/net/cpfl/cpfl_fxp_rule.c
@@ -55,8 +55,7 @@ cpfl_send_ctlq_msg(struct idpf_hw *hw, struct idpf_ctlq_info *cq, u16 num_q_msg,
 	}
 
 send_err:
-	if (msg_ptr_list)
-		free(msg_ptr_list);
+	free(msg_ptr_list);
 err:
 	return ret;
 }
diff --git a/drivers/net/nfp/nfp_ipsec.c b/drivers/net/nfp/nfp_ipsec.c
index a76ba2a91d00..c1e1862d7ce8 100644
--- a/drivers/net/nfp/nfp_ipsec.c
+++ b/drivers/net/nfp/nfp_ipsec.c
@@ -1415,8 +1415,7 @@ nfp_ipsec_init(struct rte_eth_dev *dev)
 static void
 nfp_ipsec_ctx_destroy(struct rte_eth_dev *dev)
 {
-	if (dev->security_ctx != NULL)
-		rte_free(dev->security_ctx);
+	rte_free(dev->security_ctx);
 }
 
 void
diff --git a/drivers/net/qede/base/bcm_osal.c b/drivers/net/qede/base/bcm_osal.c
index 638d0065ef14..2edeb38d6449 100644
--- a/drivers/net/qede/base/bcm_osal.c
+++ b/drivers/net/qede/base/bcm_osal.c
@@ -69,8 +69,7 @@ int ecore_mz_mapping_alloc(void)
 void ecore_mz_mapping_free(void)
 {
 	if (__atomic_fetch_sub(&ref_cnt, 1, __ATOMIC_RELAXED) - 1 == 0) {
-		if (ecore_mz_mapping)
-			rte_free(ecore_mz_mapping);
+		rte_free(ecore_mz_mapping);
 		ecore_mz_mapping = NULL;
 	}
 }
-- 
2.39.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] remove unnecessary null check before free/rte_free
  2023-10-24 22:58 [PATCH] remove unnecessary null check before free/rte_free Stephen Hemminger
@ 2023-11-06 15:46 ` Thomas Monjalon
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2023-11-06 15:46 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: dev, Akhil Goyal, Fan Zhang, Konstantin Ananyev, Ajit Khaparde,
	Somnath Kotur, Yuying Zhang, Beilei Xing, Chaoyong He,
	Devendra Singh Rawat, Alok Prasad, Srikanth Yalavarthi

25/10/2023 00:58, Stephen Hemminger:
> This is the latest round of places that are checking for NULL
> pointer before calling free or rte_free. It is result of applying
> the nullfree.cocci script.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>

Applied and re-run with more fixes in new ml/cnxk code, thanks.



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-11-06 15:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-24 22:58 [PATCH] remove unnecessary null check before free/rte_free Stephen Hemminger
2023-11-06 15:46 ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).