From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM04-SN1-obe.outbound.protection.outlook.com (mail-eopbgr700048.outbound.protection.outlook.com [40.107.70.48]) by dpdk.org (Postfix) with ESMTP id B19AC1B13A for ; Fri, 23 Nov 2018 13:11:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8J0ELswoSfjWJAtlSkOwu4EjVyPyjXBNrnzkTgPyXEs=; b=G74iMjOd75WH7mJRzZhv9Sb0yH1VHyt2DlvTab9PwuD7PTQSMNJ2PwDhA9fyXaKWHWCtL8tmos/ZQbyFiaXOMTWae/+kV8lpOccLnDwdsrrblAJk/hcJt9K+OOQWMl1kciBaC3P84nHQCnteSVD7uDtvdHqCiK3ZnXrNsuMN/EI= Received: from MWHPR07MB2783.namprd07.prod.outlook.com (10.169.237.19) by MWHPR07MB3024.namprd07.prod.outlook.com (10.172.96.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.16; Fri, 23 Nov 2018 12:10:59 +0000 Received: from MWHPR07MB2783.namprd07.prod.outlook.com ([fe80::29ab:cc5f:b87f:b0af]) by MWHPR07MB2783.namprd07.prod.outlook.com ([fe80::29ab:cc5f:b87f:b0af%4]) with mapi id 15.20.1339.031; Fri, 23 Nov 2018 12:10:59 +0000 From: Akash Saxena To: "Verma, Shally" , "john.mcnamara@intel.com" , "dev@dpdk.org" , "Sahu, Sunila" , "Athreya, Narayana Prasad" , "Gupta, Ashish" , "pablo.de.lara.guarch@intel.com" CC: "Saxena, Akash" Thread-Topic: [PATCH] crypto/openssl: Remove if condition prior to BN_free Thread-Index: AQHUgyWYjTDDdD5uSEy6QCDo+Zqdfw== Date: Fri, 23 Nov 2018 12:10:59 +0000 Message-ID: <1542974985-31428-1-git-send-email-akash.saxena@caviumnetworks.com> Accept-Language: en-IN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [115.113.156.2] x-clientproxiedby: BMXPR01CA0009.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:d::19) To MWHPR07MB2783.namprd07.prod.outlook.com (2603:10b6:300:2a::19) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Akash.Saxena@cavium.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR07MB3024; 6:dSNsNRtfk15M0Ex0oJgH3HIUvLLhbGmAtV0YCXozy76UPF4MvqgTChujI7JOGS9ITtnYi07usH5yerfl2JReSU3PL2+9aq/2eYVMD2q1Yx2vPEx8xuKPoCoXjJB2c7H3yjawAJPs+zdZAau6FurPwzIz7JlY3TLW3dimNVmxNlURqzMUR43HbyCueBThG+8EBC4J3/1YYAsQt3OxZP4UDcvvqT9ftq83no1IAokiUJPYBaVa0GckZ8QsU3A1eQXMGLmX94TkvqU10qdrjnM4mZoSKt+E00SxCGanmSno2g+RQmK3c1/ieATql1K542ZRNmzb1Mku+7hXcXLx2Xm5NH6X+u2Svc4PNP2rD+qoYBgfuiixevu3wAwvzQmKJVFpbCG0JcoFMOiMmUDAswMwkiY5uhrtS50gLosZkjtEuEo8KP3Hc2w8whtaJVUGEe/C92flwq8AKGqrvDRUqx+Uzw==; 5:1e0vgDXDSeZkDBQL86QrurhVUzBDgHPsCYHo3eVtp0YPvp+ByMg/7R8O0ULtvWShEQK8RpjCberf6vbjo3JrCEmWZ8RQidSGJYDqUAGAby5lTsk6T7kiCuORo5MYahZw3HeIpuT64ipuUd+Y9ceeftS5K63qJSy2hspdsWnjjFI=; 7:3KNkq+UGlPQ/WwKr1xoxA3YaiN/5J1JgBytmUtNY+i+Xg7zC8JERSKt/9D/vw2l5BLoe7V+nbwEVz4nu1pY/XJ1XS8XpC4mjWhu5RISJfcoVgxrHFTbHlOyVyvSHqdkY5lSaTI49rmGzTdHpwWTeSA== x-ms-office365-filtering-correlation-id: edb02be9-3969-4b1a-4819-08d6513cba3e x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:MWHPR07MB3024; x-ms-traffictypediagnostic: MWHPR07MB3024: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(3231442)(944501410)(52105112)(10201501046)(3002001)(148016)(149066)(150057)(6041310)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(201708071742011)(7699051)(76991095); SRVR:MWHPR07MB3024; BCL:0; PCL:0; RULEID:; SRVR:MWHPR07MB3024; x-forefront-prvs: 086597191B x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(136003)(396003)(346002)(366004)(39860400002)(376002)(199004)(189003)(110136005)(575784001)(6486002)(2201001)(316002)(305945005)(107886003)(1857600001)(2616005)(476003)(26005)(186003)(7736002)(486006)(6512007)(36756003)(106356001)(42882007)(105586002)(53936002)(99286004)(55236004)(4326008)(102836004)(6436002)(386003)(6506007)(52116002)(25786009)(3846002)(6116002)(81156014)(71200400001)(71190400001)(68736007)(8676002)(81166006)(14444005)(256004)(2906002)(72206003)(8936002)(2501003)(2900100001)(66066001)(97736004)(478600001)(14454004)(5660300001)(921003)(1121003); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR07MB3024; H:MWHPR07MB2783.namprd07.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: nAM/cGa13JmnkXMaRbD9fg8jWIfTVOyseKqRpDZRx3Ya912UM5lW6a0Nf0RVItBqRUEmwCgN3lgQ/+bmCXZyJq9XndK8gMvBfjc5kvwhk08PF3BrCJk5953Qi2LDLnbTj9EFwBXq3UF4M+Ts0FNzgXYOAE9/ary8gauckfpOjqsZcAdhe0gZF86n/ja6x1PmvBL82l+kJYK+hJgZukX4SdBVEsq1HBD3cVtF1yrkhW3YPrKtirYWkDZe6yNbQW9qeYKzNMrZC8E35JFmZCmcL/GpaeaUAOage28eXs/X8yjBadcqOUep8obfI3Zkm/sZ0EO9WoTlvI9Q6m1X91dVVA2NtUcc4tSkL3WaNOYAMOU= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-Network-Message-Id: edb02be9-3969-4b1a-4819-08d6513cba3e X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Nov 2018 12:10:59.1441 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR07MB3024 Subject: [dpdk-dev] [PATCH] crypto/openssl: Remove if condition prior to BN_free X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Nov 2018 12:11:02 -0000 Remove if() condition prior to calling BN_free() as BN_free(a) does nothing if a is NULL. Signed-off-by: Akash Saxena Signed-off-by: Shally Verma --- drivers/crypto/openssl/rte_openssl_pmd.c | 21 +++++-------- drivers/crypto/openssl/rte_openssl_pmd_ops.c | 45 ++++++++++--------------= ---- 2 files changed, 22 insertions(+), 44 deletions(-) diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/open= ssl/rte_openssl_pmd.c index 11ea0d1..a0ccacb 100644 --- a/drivers/crypto/openssl/rte_openssl_pmd.c +++ b/drivers/crypto/openssl/rte_openssl_pmd.c @@ -1605,12 +1605,9 @@ process_openssl_dsa_verify_op(struct rte_crypto_op *= cop, op->y.length, pub_key); if (!r || !s || !pub_key) { - if (r) - BN_free(r); - if (s) - BN_free(s); - if (pub_key) - BN_free(pub_key); + BN_free(r); + BN_free(s); + BN_free(pub_key); =20 cop->status =3D RTE_CRYPTO_OP_STATUS_NOT_PROCESSED; return -1; @@ -1781,10 +1778,8 @@ process_openssl_modinv_op(struct rte_crypto_op *cop, BIGNUM *res =3D BN_CTX_get(sess->u.m.ctx); =20 if (unlikely(base =3D=3D NULL || res =3D=3D NULL)) { - if (base) - BN_free(base); - if (res) - BN_free(res); + BN_free(base); + BN_free(res); cop->status =3D RTE_CRYPTO_OP_STATUS_NOT_PROCESSED; return -1; } @@ -1812,10 +1807,8 @@ process_openssl_modexp_op(struct rte_crypto_op *cop, BIGNUM *res =3D BN_CTX_get(sess->u.e.ctx); =20 if (unlikely(base =3D=3D NULL || res =3D=3D NULL)) { - if (base) - BN_free(base); - if (res) - BN_free(res); + BN_free(base); + BN_free(res); cop->status =3D RTE_CRYPTO_OP_STATUS_NOT_PROCESSED; return -1; } diff --git a/drivers/crypto/openssl/rte_openssl_pmd_ops.c b/drivers/crypto/= openssl/rte_openssl_pmd_ops.c index c2b029e..bdaf937 100644 --- a/drivers/crypto/openssl/rte_openssl_pmd_ops.c +++ b/drivers/crypto/openssl/rte_openssl_pmd_ops.c @@ -906,22 +906,14 @@ static int openssl_set_asym_session_parameters( asym_session->xfrm_type =3D RTE_CRYPTO_ASYM_XFORM_RSA; break; err_rsa: - if (n) - BN_free(n); - if (e) - BN_free(e); - if (d) - BN_free(d); - if (p) - BN_free(p); - if (q) - BN_free(q); - if (dmp1) - BN_free(dmp1); - if (dmq1) - BN_free(dmq1); - if (iqmp) - BN_free(iqmp); + BN_free(n); + BN_free(e); + BN_free(d); + BN_free(p); + BN_free(q); + BN_free(dmp1); + BN_free(dmq1); + BN_free(iqmp); =20 return -1; } @@ -1043,10 +1035,8 @@ static int openssl_set_asym_session_parameters( =20 err_dh: OPENSSL_LOG(ERR, " failed to set dh params\n"); - if (p) - BN_free(p); - if (g) - BN_free(g); + BN_free(p); + BN_free(g); return -1; } case RTE_CRYPTO_ASYM_XFORM_DSA: @@ -1112,16 +1102,11 @@ static int openssl_set_asym_session_parameters( break; =20 err_dsa: - if (p) - BN_free(p); - if (q) - BN_free(q); - if (g) - BN_free(g); - if (priv_key) - BN_free(priv_key); - if (pub_key) - BN_free(pub_key); + BN_free(p); + BN_free(q); + BN_free(g); + BN_free(priv_key); + BN_free(pub_key); return -1; } default: --=20 2.7.4