Skip to contentSkip to conversation

cryptodev: fix PMD memory leak

PATCH Applied Fan Zhang 2 participants 3 messages Dec 21, 2018 – Jan 8, 2019 Crypto API

lore
Share & tools
lore

Fan Zhang

author
#0 lore raw

PATCH 1/1 cryptodev: fix PMD memory leak

This patch fixes the memory leak during queue pair release. Originally the operation ring is not freed when releasing queue pair, cause the next queue_pair configure call fail and memory leak.

Fixes eec136f3c54f ("aesni_gcm: add driver for AES-GCM crypto operations")
Fixes cf7685d68f00 ("crypto/zuc: add driver for ZUC library")
Fixes d61f70b4c918 ("crypto/libcrypto: add driver for OpenSSL library")
Fixes 3aafc423cf4d ("snow3g: add driver for SNOW 3G library")
---
 drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c | 5 +++++
 drivers/crypto/openssl/rte_openssl_pmd_ops.c | 5 +++++
 drivers/crypto/snow3g/rte_snow3g_pmd_ops.c   | 5 +++++
 drivers/crypto/zuc/rte_zuc_pmd_ops.c         | 5 +++++
 4 files changed, 20 insertions(+)
drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c +5 -0
index 2f70f2a1a..bf69dde54 100644
@@ -153,6 +153,11 @@ static int
 aesni_gcm_pmd_qp_release(struct rte_cryptodev *dev, uint16_t qp_id)
 {
 	if (dev->data->queue_pairs[qp_id] != NULL) {
+		struct aesni_gcm_qp *qp = dev->data->queue_pairs[qp_id];
+
+		if (qp->processed_pkts)
+			rte_ring_free(qp->processed_pkts);
+
 		rte_free(dev->data->queue_pairs[qp_id]);
 		dev->data->queue_pairs[qp_id] = NULL;
 	}
drivers/crypto/openssl/rte_openssl_pmd_ops.c +5 -0
index 5644f593a..40217cf0d 100644
@@ -657,6 +657,11 @@ static int
 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_free(dev->data->queue_pairs[qp_id]);
 		dev->data->queue_pairs[qp_id] = NULL;
 	}
drivers/crypto/snow3g/rte_snow3g_pmd_ops.c +5 -0
index fad483c75..d2125233f 100644
@@ -142,6 +142,11 @@ static int
 snow3g_pmd_qp_release(struct rte_cryptodev *dev, uint16_t qp_id)
 {
 	if (dev->data->queue_pairs[qp_id] != NULL) {
+		struct snow3g_qp *qp = dev->data->queue_pairs[qp_id];
+
+		if (qp->processed_ops)
+			rte_ring_free(qp->processed_ops);
+
 		rte_free(dev->data->queue_pairs[qp_id]);
 		dev->data->queue_pairs[qp_id] = NULL;
 	}
drivers/crypto/zuc/rte_zuc_pmd_ops.c +5 -0
index 7bd985fc1..1b88947eb 100644
@@ -142,6 +142,11 @@ static int
 zuc_pmd_qp_release(struct rte_cryptodev *dev, uint16_t qp_id)
 {
 	if (dev->data->queue_pairs[qp_id] != NULL) {
+		struct zuc_qp *qp = dev->data->queue_pairs[qp_id];
+
+		if (qp->processed_ops)
+			rte_ring_free(qp->processed_ops);
+
 		rte_free(dev->data->queue_pairs[qp_id]);
 		dev->data->queue_pairs[qp_id] = NULL;
 	}
Signature · 1 line
2.13.6
Acked-by on v1 1/1
#1 lore raw
Quoted 22 lines

-----Original Message-----
From: Zhang, Roy Fan
Sent: Friday, December 21, 2018 2:11 PM
To: [email protected]
Cc: [email protected]; De Lara Guarch, Pablo <[email protected]>; Trahe, Fiona <[email protected]>; [email protected]
Subject: [PATCH] cryptodev: fix PMD memory leak

This patch fixes the memory leak during queue pair release. Originally the operation ring is not freed when releasing queue pair, cause the next queue_pair configure call fail and memory leak.

Fixes eec136f3c54f ("aesni_gcm: add driver for AES-GCM crypto operations")
Fixes cf7685d68f00 ("crypto/zuc: add driver for ZUC library")
Fixes d61f70b4c918 ("crypto/libcrypto: add driver for OpenSSL library")
Fixes 3aafc423cf4d ("snow3g: add driver for SNOW 3G library")
Quoted 7 lines
---
 drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c | 5 +++++
drivers/crypto/openssl/rte_openssl_pmd_ops.c | 5 +++++
 drivers/crypto/snow3g/rte_snow3g_pmd_ops.c   | 5 +++++
 drivers/crypto/zuc/rte_zuc_pmd_ops.c         | 5 +++++
 4 files changed, 20 insertions(+)

Title should be renamed to "drivers/crypto:".

Apart from that,

#2 lore raw
Quoted 43 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of De Lara Guarch, Pablo
Sent: Friday, December 21, 2018 3:44 PM
To: Zhang, Roy Fan <[email protected]>; [email protected]
Cc: [email protected]; Trahe, Fiona <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH] cryptodev: fix PMD memory leak

Quoted 22 lines

-----Original Message-----
From: Zhang, Roy Fan
Sent: Friday, December 21, 2018 2:11 PM
To: [email protected]
Cc: [email protected]; De Lara Guarch, Pablo
<[email protected]>; Trahe, Fiona
<[email protected]>; [email protected]
Subject: [PATCH] cryptodev: fix PMD memory leak

This patch fixes the memory leak during queue pair release. Originally the operation ring is not freed when releasing queue pair, cause the next queue_pair configure call fail and memory leak.

Fixes eec136f3c54f ("aesni_gcm: add driver for AES-GCM crypto

operations")

Fixes cf7685d68f00 ("crypto/zuc: add driver for ZUC library")
Fixes d61f70b4c918 ("crypto/libcrypto: add driver for OpenSSL

library")

Fixes 3aafc423cf4d ("snow3g: add driver for SNOW 3G library")
Quoted 7 lines
---
 drivers/crypto/aesni_gcm/aesni_gcm_pmd_ops.c | 5 +++++
drivers/crypto/openssl/rte_openssl_pmd_ops.c | 5 +++++
 drivers/crypto/snow3g/rte_snow3g_pmd_ops.c   | 5 +++++
 drivers/crypto/zuc/rte_zuc_pmd_ops.c         | 5 +++++
 4 files changed, 20 insertions(+)
Quoted 5 lines

Title should be renamed to "drivers/crypto:".

Apart from that,

Applied to dpdk-next-crypto.

Thanks,
Pablo