[2/2] net/bnxt: remove unnecessary check for null before free

Message ID 20230804164156.118331-2-stephen@networkplumber.org (mailing list archive)
State Superseded
Delegated to: Thomas Monjalon
Headers
Series [1/2] app/test: remove unnecessary null check before free |

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/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch-unit-testing success Testing PASS
ci/iol-unit-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing 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

Commit Message

Stephen Hemminger Aug. 4, 2023, 4:41 p.m. UTC
  No need to check for null pointer before calling rte_free().
Found by cocci/nullfree.cocci script.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/bnxt/bnxt_ethdev.c | 3 +--
 drivers/net/bnxt/bnxt_vnic.c   | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
  

Patch

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index ee1552452a11..ec8e441a6d05 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -6002,8 +6002,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;
 }