From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 44BCD431F3; Wed, 25 Oct 2023 00:59:02 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B892D4029A; Wed, 25 Oct 2023 00:59:01 +0200 (CEST) Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) by mails.dpdk.org (Postfix) with ESMTP id 870684028B for ; Wed, 25 Oct 2023 00:59:00 +0200 (CEST) Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-6be840283ceso4138337b3a.3 for ; Tue, 24 Oct 2023 15:59:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1698188339; x=1698793139; darn=dpdk.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=P1TQeomMCY1pupDlsprXkG5l2ewQdx+ArGON9Rcf4jQ=; b=GohHPxSTlT9TM+zq0G+sif52CHyYkMH6G1aOp63pQ8fo1D+t5BVaI2kQl5XsfdFikK Kf3t2DH/PIom/sIuCO3dNm/AJkCVGCIfrWFfvbE7f/8x9YGxv/SR9ZPOVAfUGBWzKOPK QFYUN5vcmAhR5WDAahSYbF7UDTMcIPgeReBxiQXz9d51NZfWmfFM+IHP5AhrwXhmBz9i 0ZLoxFdnVSyjljjSw8pdm+W6Kwo3Mkf9z1Ki+kXXUStea2Cg4Rh9LehrbTvZTr/zysh9 2uE4ktFAZy3bz+70UZ+s/dktpyVQxCuqxxeheYoBuuWzwTyKOoww+BkisUIthTMDkcHI Cfjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698188339; x=1698793139; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=P1TQeomMCY1pupDlsprXkG5l2ewQdx+ArGON9Rcf4jQ=; b=qdRVT1uRSqUfDxgByqX5pUnKZY+ja4WBd//KKN6foaQ4FZXL+QSRMcoEEePbL//C1C AJJ7UkXP4VP6pVyYTNDCgx/srcYbsSnTiXNn+AZa3lAB0448bhj0LfjDAv0N7vdzBWJ6 PuDS2qs5gFoLki5TkPYfOJqOJH0ODSwFVLk13lv+NxC5Ac2JOXPN1LXDmge7GluhI5Vy GRJFADa/ilK1+OAJUWsKonMKpbghse661dlD8aWkGCm3QKBtkQDaHn6kfpT5N32r4m/g 1oYzW6uukD9Gy34HscvoTSByoOG+OBS4bql2by20+Ng0mERuZLRtUsG75CIn9EUamIky nQlA== X-Gm-Message-State: AOJu0Yxe8Ayly+Jlh5I9GhrckxWp2QCm5hvkOjEXcxZZlqYx27Ye/9Fp c5/aJC60810Y+U55NFUDdiCp5yKuPhhqOTW5YlMOWA== X-Google-Smtp-Source: AGHT+IEqxtDOU+E2XTYAJr0gghUbFslRtHVsmQO2UIgykqk5YYLLHaP3ZtQkuMZbO25hQL4XHWateQ== X-Received: by 2002:a05:6a00:1749:b0:692:b6e8:ce88 with SMTP id j9-20020a056a00174900b00692b6e8ce88mr12198399pfc.17.1698188339120; Tue, 24 Oct 2023 15:58:59 -0700 (PDT) Received: from hermes.local (204-195-126-68.wavecable.com. [204.195.126.68]) by smtp.gmail.com with ESMTPSA id v26-20020aa799da000000b006c0328b2440sm22450pfi.150.2023.10.24.15.58.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 15:58:58 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Akhil Goyal , Fan Zhang , Konstantin Ananyev , Ajit Khaparde , Somnath Kotur , Yuying Zhang , Beilei Xing , Chaoyong He , Devendra Singh Rawat , Alok Prasad Subject: [PATCH] remove unnecessary null check before free/rte_free Date: Tue, 24 Oct 2023 15:58:47 -0700 Message-Id: <20231024225847.6478-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 --- 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