crypto/openssl: fix memory free issue

Message ID 20230511135944.142416-1-ciara.power@intel.com (mailing list archive)
State Accepted, archived
Delegated to: akhil goyal
Headers
Series crypto/openssl: fix memory free issue |

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

Commit Message

Power, Ciara May 11, 2023, 1:59 p.m. UTC
  From: Saoirse O'Donovan <saoirse.odonovan@intel.com>

Allocated memory was being freed using 'free' when it should have been
freed using 'OPENSSL_free'. This has now been modified so that the
correct method is used to free allocated memory.

Coverity issue: 384415
Fixes: 4c7ae22f1f83 ("crypto/openssl: update DSA routine with 3.0 EVP API")
Cc: kai.ji@intel.com
Cc: stable@dpdk.org

Signed-off-by: Saoirse O'Donovan <saoirse.odonovan@intel.com>
Signed-off-by: Ciara Power <ciara.power@intel.com>
---
 drivers/crypto/openssl/rte_openssl_pmd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
  

Comments

Ji, Kai May 11, 2023, 2:26 p.m. UTC | #1
Acked-by: Kai Ji <kai.ji@intel.com>

> -----Original Message-----
> From: Power, Ciara <ciara.power@intel.com>
> Sent: Thursday, May 11, 2023 3:00 PM
> To: Ji, Kai <kai.ji@intel.com>
> Cc: dev@dpdk.org; O'Donovan, Saoirse <saoirse.odonovan@intel.com>;
> stable@dpdk.org; Power, Ciara <ciara.power@intel.com>
> Subject: [PATCH] crypto/openssl: fix memory free issue
> 
> From: Saoirse O'Donovan <saoirse.odonovan@intel.com>
> 
> Allocated memory was being freed using 'free' when it should have been
> freed using 'OPENSSL_free'. This has now been modified so that the correct
> method is used to free allocated memory.
> 
> Coverity issue: 384415
> Fixes: 4c7ae22f1f83 ("crypto/openssl: update DSA routine with 3.0 EVP API")
> Cc: kai.ji@intel.com
> Cc: stable@dpdk.org
> 
> Signed-off-by: Saoirse O'Donovan <saoirse.odonovan@intel.com>
> Signed-off-by: Ciara Power <ciara.power@intel.com>
> ---
  
Akhil Goyal May 24, 2023, 12:11 p.m. UTC | #2
> Acked-by: Kai Ji <kai.ji@intel.com>
> 
> > Subject: [PATCH] crypto/openssl: fix memory free issue
> >
> > From: Saoirse O'Donovan <saoirse.odonovan@intel.com>
> >
> > Allocated memory was being freed using 'free' when it should have been
> > freed using 'OPENSSL_free'. This has now been modified so that the correct
> > method is used to free allocated memory.
> >
> > Coverity issue: 384415
> > Fixes: 4c7ae22f1f83 ("crypto/openssl: update DSA routine with 3.0 EVP API")
> > Cc: kai.ji@intel.com
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Saoirse O'Donovan <saoirse.odonovan@intel.com>
> > Signed-off-by: Ciara Power <ciara.power@intel.com>
> > ---

Applied to dpdk-next-crypto

Thanks.
  

Patch

diff --git a/drivers/crypto/openssl/rte_openssl_pmd.c b/drivers/crypto/openssl/rte_openssl_pmd.c
index 384d262621..f65fbca300 100644
--- a/drivers/crypto/openssl/rte_openssl_pmd.c
+++ b/drivers/crypto/openssl/rte_openssl_pmd.c
@@ -1927,7 +1927,7 @@  process_openssl_dsa_sign_op_evp(struct rte_crypto_op *cop,
 
 	if (EVP_PKEY_sign(dsa_ctx, dsa_sign_data, &outlen, op->message.data,
 						op->message.length) <= 0) {
-		free(dsa_sign_data);
+		OPENSSL_free(dsa_sign_data);
 		goto err_dsa_sign;
 	}
 
@@ -1935,7 +1935,7 @@  process_openssl_dsa_sign_op_evp(struct rte_crypto_op *cop,
 	DSA_SIG *sign = d2i_DSA_SIG(NULL, &dsa_sign_data_p, outlen);
 	if (!sign) {
 		OPENSSL_LOG(ERR, "%s:%d\n", __func__, __LINE__);
-		free(dsa_sign_data);
+		OPENSSL_free(dsa_sign_data);
 		goto err_dsa_sign;
 	} else {
 		const BIGNUM *r = NULL, *s = NULL;
@@ -1947,7 +1947,7 @@  process_openssl_dsa_sign_op_evp(struct rte_crypto_op *cop,
 	}
 
 	DSA_SIG_free(sign);
-	free(dsa_sign_data);
+	OPENSSL_free(dsa_sign_data);
 	return 0;
 
 err_dsa_sign: