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 920F6A034E; Wed, 9 Feb 2022 20:19:23 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6E86E41161; Wed, 9 Feb 2022 20:18:09 +0100 (CET) Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by mails.dpdk.org (Postfix) with ESMTP id 4FBF141181 for ; Wed, 9 Feb 2022 20:18:07 +0100 (CET) Received: by mail-pf1-f173.google.com with SMTP id y8so3245894pfa.11 for ; Wed, 09 Feb 2022 11:18:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=C32nqkA0C+zSthTawdcy1VYW7mZmedGQR4fRtMInSwo=; b=eLKT3VDpXAZ08Bi8hEIQPfBuZ2h/+UlUWVcJDVpoRZ4+vuqgGs++SFWwj22B1RAqsc p1TqRfHVYKvIUrT438vAimFZqwv3kSAjmuHRFZSC650G7qJIis2VkHK5in8YUXzwCW0U NK+XHzlE7WE2XncJeXtqR3hYUNEeOKtGRvz0KZ+7U8zyTSxZUHkTRK7ajHRy/HRrqOz4 pYd485KuM9Yz+ujktaXIy/dmjVncTuDHHzl20yAmi3VBweqFb9Zn1Rp5WENdvIu4552i Lv/i9RqMHDVb4hQHRS30KHPTMbbDhvXc0C5wfpT3PmwpPO0A10kyX5vSLZlKzIgbuZfD 5ehA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=C32nqkA0C+zSthTawdcy1VYW7mZmedGQR4fRtMInSwo=; b=UPDxE1U+iByUPavbSDOR9qnMu8qMY+NPNiQKv0DYnFqEF+lS/GpyRHoQnS9BQ6ZYdy k8vmW8k7/PFqd+lgSZiojmjVgBRJCpKB/XQ9HsJIOnXa05EVfltO/CBLtQi7kDn+aYxU 6Ja3TDpvRoQwqtcr2hhDUwkCAhpm9PROr6zcQF+AtSjQliqRPIOhOJ81SswVAn4TdyH4 qstOrnPZcR7nNcTtpC4FFPCC9kAubQOZSphcH8D140HeT1p8iKof/Vdybx8qZmvTxxNz aZgvriPdzvr50Wc+Qx7IJvgdd74gelqq7hBDBqrw3Xor0oxDaiRknKj3d4npdLMxGvzo wvLg== X-Gm-Message-State: AOAM530m9f5XpMVJF+czGA7slfqetH5XeeK8gBt54iDHXsMFU2OT6zib K34sLlOHUyLrmPXpjImgw68PkFq1EDqaOnDeIFc= X-Google-Smtp-Source: ABdhPJwjEworHiO5fOfr3F0jmuTf4cPO+F4BHRp8+f0cSN5Pa8bm8ExjGH+pwTU+GXXt81Pc2/tANA== X-Received: by 2002:a63:6847:: with SMTP id d68mr3097744pgc.273.1644434286191; Wed, 09 Feb 2022 11:18:06 -0800 (PST) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id u16sm14378401pgh.54.2022.02.09.11.18.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 11:18:05 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Ruifeng Wang , Fan Zhang , Chandubabu Namburu , Ankur Dwivedi , Anoob Joseph , Tejasree Kondoj , Pablo de Lara , Michael Shamis , Liron Himi , Declan Doherty , Jay Zhou Subject: [PATCH v3 12/36] crypto: remove unnecessary NULL checks Date: Wed, 9 Feb 2022 11:17:24 -0800 Message-Id: <20220209191748.377729-13-stephen@networkplumber.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220209191748.377729-1-stephen@networkplumber.org> References: <20220124000518.319850-1-stephen@networkplumber.org> <20220209191748.377729-1-stephen@networkplumber.org> 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 Remove redundant NULL pointer checks before free functions found by nullfree.cocci Signed-off-by: Stephen Hemminger Acked-by: Ruifeng Wang Acked-by: Fan Zhang --- drivers/crypto/armv8/rte_armv8_pmd_ops.c | 3 +-- drivers/crypto/ccp/ccp_dev.c | 3 +-- drivers/crypto/ccp/ccp_pmd_ops.c | 3 +-- drivers/crypto/cnxk/cnxk_ae.h | 6 ++---- drivers/crypto/ipsec_mb/ipsec_mb_ops.c | 3 +-- drivers/crypto/mvsam/rte_mrvl_pmd_ops.c | 6 ++---- drivers/crypto/null/null_crypto_pmd_ops.c | 6 ++---- drivers/crypto/octeontx/otx_cryptodev_ops.c | 3 +-- drivers/crypto/openssl/rte_openssl_pmd_ops.c | 6 ++---- drivers/crypto/scheduler/scheduler_pmd_ops.c | 6 ++---- drivers/crypto/virtio/virtqueue.c | 6 ++---- 11 files changed, 17 insertions(+), 34 deletions(-) diff --git a/drivers/crypto/armv8/rte_armv8_pmd_ops.c b/drivers/crypto/armv8/rte_armv8_pmd_ops.c index 1b2749fe62c6..c07ac0489e57 100644 --- a/drivers/crypto/armv8/rte_armv8_pmd_ops.c +++ b/drivers/crypto/armv8/rte_armv8_pmd_ops.c @@ -251,8 +251,7 @@ armv8_crypto_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id, return 0; qp_setup_cleanup: - if (qp) - rte_free(qp); + rte_free(qp); return -1; } diff --git a/drivers/crypto/ccp/ccp_dev.c b/drivers/crypto/ccp/ccp_dev.c index 0eb1b0328ef0..424ead82c3aa 100644 --- a/drivers/crypto/ccp/ccp_dev.c +++ b/drivers/crypto/ccp/ccp_dev.c @@ -673,8 +673,7 @@ ccp_probe_device(int ccp_type, struct rte_pci_device *pci_dev) CCP_LOG_ERR("CCP Device probe failed"); if (uio_fd >= 0) close(uio_fd); - if (ccp_dev) - rte_free(ccp_dev); + rte_free(ccp_dev); return -1; } diff --git a/drivers/crypto/ccp/ccp_pmd_ops.c b/drivers/crypto/ccp/ccp_pmd_ops.c index 0d615d311c9b..1b600e81ad5c 100644 --- a/drivers/crypto/ccp/ccp_pmd_ops.c +++ b/drivers/crypto/ccp/ccp_pmd_ops.c @@ -744,8 +744,7 @@ ccp_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id, qp_setup_cleanup: dev->data->queue_pairs[qp_id] = NULL; - if (qp) - rte_free(qp); + rte_free(qp); return -1; } diff --git a/drivers/crypto/cnxk/cnxk_ae.h b/drivers/crypto/cnxk/cnxk_ae.h index 6222171fe603..01ccfcd33432 100644 --- a/drivers/crypto/cnxk/cnxk_ae.h +++ b/drivers/crypto/cnxk/cnxk_ae.h @@ -196,13 +196,11 @@ cnxk_ae_free_session_parameters(struct cnxk_ae_sess *sess) switch (sess->xfrm_type) { case RTE_CRYPTO_ASYM_XFORM_RSA: rsa = &sess->rsa_ctx; - if (rsa->n.data) - rte_free(rsa->n.data); + rte_free(rsa->n.data); break; case RTE_CRYPTO_ASYM_XFORM_MODEX: mod = &sess->mod_ctx; - if (mod->modulus.data) - rte_free(mod->modulus.data); + rte_free(mod->modulus.data); break; case RTE_CRYPTO_ASYM_XFORM_ECDSA: /* Fall through */ diff --git a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c index 1ebd23e8f073..1cf37e983617 100644 --- a/drivers/crypto/ipsec_mb/ipsec_mb_ops.c +++ b/drivers/crypto/ipsec_mb/ipsec_mb_ops.c @@ -102,8 +102,7 @@ ipsec_mb_qp_release(struct rte_cryptodev *dev, uint16_t qp_id) if (qp != NULL && rte_eal_process_type() == RTE_PROC_PRIMARY) { r = rte_ring_lookup(qp->name); - if (r) - rte_ring_free(r); + rte_ring_free(r); #if IMB_VERSION(1, 1, 0) > IMB_VERSION_NUM if (qp->mb_mgr) diff --git a/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c b/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c index 3064b1f136fe..f828dc9db5f6 100644 --- a/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c +++ b/drivers/crypto/mvsam/rte_mrvl_pmd_ops.c @@ -774,10 +774,8 @@ mrvl_crypto_pmd_sym_session_configure(__rte_unused struct rte_cryptodev *dev, } /* free the keys memory allocated for session creation */ - if (mrvl_sess->sam_sess_params.cipher_key != NULL) - free(mrvl_sess->sam_sess_params.cipher_key); - if (mrvl_sess->sam_sess_params.auth_key != NULL) - free(mrvl_sess->sam_sess_params.auth_key); + free(mrvl_sess->sam_sess_params.cipher_key); + free(mrvl_sess->sam_sess_params.auth_key); return 0; } diff --git a/drivers/crypto/null/null_crypto_pmd_ops.c b/drivers/crypto/null/null_crypto_pmd_ops.c index a8b5a06e7f4e..90a675dfffe0 100644 --- a/drivers/crypto/null/null_crypto_pmd_ops.c +++ b/drivers/crypto/null/null_crypto_pmd_ops.c @@ -135,8 +135,7 @@ null_crypto_pmd_qp_release(struct rte_cryptodev *dev, uint16_t qp_id) if (dev->data->queue_pairs[qp_id] != NULL) { struct null_crypto_qp *qp = dev->data->queue_pairs[qp_id]; - if (qp->processed_pkts) - rte_ring_free(qp->processed_pkts); + rte_ring_free(qp->processed_pkts); rte_free(dev->data->queue_pairs[qp_id]); dev->data->queue_pairs[qp_id] = NULL; @@ -241,8 +240,7 @@ null_crypto_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id, return 0; qp_setup_cleanup: - if (qp) - rte_free(qp); + rte_free(qp); return -1; } diff --git a/drivers/crypto/octeontx/otx_cryptodev_ops.c b/drivers/crypto/octeontx/otx_cryptodev_ops.c index f7ca8a8a8e90..f1aae481c3c6 100644 --- a/drivers/crypto/octeontx/otx_cryptodev_ops.c +++ b/drivers/crypto/octeontx/otx_cryptodev_ops.c @@ -335,8 +335,7 @@ sym_session_clear(int driver_id, struct rte_cryptodev_sym_session *sess) misc = priv; ctx = SESS_PRIV(misc); - if (ctx->auth_key != NULL) - rte_free(ctx->auth_key); + rte_free(ctx->auth_key); memset(priv, 0, cpt_get_session_size()); diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c b/drivers/crypto/openssl/rte_openssl_pmd_ops.c index 52715f86f84a..b1c0b14fefd2 100644 --- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c +++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c @@ -659,8 +659,7 @@ openssl_pmd_qp_release(struct rte_cryptodev *dev, uint16_t qp_id) if (dev->data->queue_pairs[qp_id] != NULL) { struct openssl_qp *qp = dev->data->queue_pairs[qp_id]; - if (qp->processed_ops) - rte_ring_free(qp->processed_ops); + rte_ring_free(qp->processed_ops); rte_free(dev->data->queue_pairs[qp_id]); dev->data->queue_pairs[qp_id] = NULL; @@ -748,8 +747,7 @@ openssl_pmd_qp_setup(struct rte_cryptodev *dev, uint16_t qp_id, return 0; qp_setup_cleanup: - if (qp) - rte_free(qp); + rte_free(qp); return -1; } diff --git a/drivers/crypto/scheduler/scheduler_pmd_ops.c b/drivers/crypto/scheduler/scheduler_pmd_ops.c index f61640c9d646..f3a1bd626c6f 100644 --- a/drivers/crypto/scheduler/scheduler_pmd_ops.c +++ b/drivers/crypto/scheduler/scheduler_pmd_ops.c @@ -371,10 +371,8 @@ scheduler_pmd_qp_release(struct rte_cryptodev *dev, uint16_t qp_id) if (!qp_ctx) return 0; - if (qp_ctx->order_ring) - rte_ring_free(qp_ctx->order_ring); - if (qp_ctx->private_qp_ctx) - rte_free(qp_ctx->private_qp_ctx); + rte_ring_free(qp_ctx->order_ring); + rte_free(qp_ctx->private_qp_ctx); rte_free(qp_ctx); dev->data->queue_pairs[qp_id] = NULL; diff --git a/drivers/crypto/virtio/virtqueue.c b/drivers/crypto/virtio/virtqueue.c index fd8be581c996..3e2db1ebd250 100644 --- a/drivers/crypto/virtio/virtqueue.c +++ b/drivers/crypto/virtio/virtqueue.c @@ -32,10 +32,8 @@ virtqueue_detatch_unused(struct virtqueue *vq) for (idx = 0; idx < vq->vq_nentries; idx++) { cop = vq->vq_descx[idx].crypto_op; if (cop) { - if (cop->sym->m_src) - rte_pktmbuf_free(cop->sym->m_src); - if (cop->sym->m_dst) - rte_pktmbuf_free(cop->sym->m_dst); + rte_pktmbuf_free(cop->sym->m_src); + rte_pktmbuf_free(cop->sym->m_dst); rte_crypto_op_free(cop); vq->vq_descx[idx].crypto_op = NULL; } -- 2.34.1