From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
Akhil Goyal <gakhil@marvell.com>,
Fan Zhang <fanzhang.oss@gmail.com>,
Konstantin Ananyev <konstantin.v.ananyev@yandex.ru>,
Ajit Khaparde <ajit.khaparde@broadcom.com>,
Somnath Kotur <somnath.kotur@broadcom.com>,
Yuying Zhang <yuying.zhang@intel.com>,
Beilei Xing <beilei.xing@intel.com>,
Chaoyong He <chaoyong.he@corigine.com>,
Devendra Singh Rawat <dsinghrawat@marvell.com>,
Alok Prasad <palok@marvell.com>
Subject: [PATCH] remove unnecessary null check before free/rte_free
Date: Tue, 24 Oct 2023 15:58:47 -0700 [thread overview]
Message-ID: <20231024225847.6478-1-stephen@networkplumber.org> (raw)
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
next reply other threads:[~2023-10-24 22:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-24 22:58 Stephen Hemminger [this message]
2023-11-06 15:46 ` [PATCH] remove unnecessary null check before free/rte_free Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231024225847.6478-1-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=ajit.khaparde@broadcom.com \
--cc=beilei.xing@intel.com \
--cc=chaoyong.he@corigine.com \
--cc=dev@dpdk.org \
--cc=dsinghrawat@marvell.com \
--cc=fanzhang.oss@gmail.com \
--cc=gakhil@marvell.com \
--cc=konstantin.v.ananyev@yandex.ru \
--cc=palok@marvell.com \
--cc=somnath.kotur@broadcom.com \
--cc=yuying.zhang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.