pipeline: fix IPsec crypto session leak

Message ID 20230207181542.655091-1-cristian.dumitrescu@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series pipeline: fix IPsec crypto session leak |

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

Commit Message

Cristian Dumitrescu Feb. 7, 2023, 6:15 p.m. UTC
  In case of rte_ipsec_session_prepare() error, the crypto session was
not freed, leading to its leakage.

Fixes: 20777eb5f913 ("pipeline: add IPsec")
Coverity issue: 383139

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
 lib/pipeline/rte_swx_ipsec.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
  

Comments

Thomas Monjalon Feb. 19, 2023, 10:09 p.m. UTC | #1
07/02/2023 19:15, Cristian Dumitrescu:
> In case of rte_ipsec_session_prepare() error, the crypto session was
> not freed, leading to its leakage.
> 
> Fixes: 20777eb5f913 ("pipeline: add IPsec")
> Coverity issue: 383139
> 
> Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

Applied, thanks.
  

Patch

diff --git a/lib/pipeline/rte_swx_ipsec.c b/lib/pipeline/rte_swx_ipsec.c
index b23056e23e..6c217ee797 100644
--- a/lib/pipeline/rte_swx_ipsec.c
+++ b/lib/pipeline/rte_swx_ipsec.c
@@ -1719,7 +1719,11 @@  ipsec_session_create(struct rte_swx_ipsec *ipsec,
 	s->pkt_func.prepare.async = NULL;
 	s->pkt_func.process = NULL;
 
-	return rte_ipsec_session_prepare(s);
+	status = rte_ipsec_session_prepare(s);
+	if (status)
+		goto error;
+
+	return 0;
 
 error:
 	/* sa. */