diff mbox series

[API-NEXT,v3,6/10] linux-generic: crypto: don't leak sessions if creation fails

Message ID 1494540010-25779-7-git-send-email-odpbot@yandex.ru
State Superseded
Headers show
Series [API-NEXT,v3,1/10] api: ipsec: add soft limit expiration event | expand

Commit Message

Github ODP bot May 11, 2017, 10 p.m. UTC
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


We should free allocated session in odp_crypto_session_create() error
paths, so that the session is not leaked.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

---
/** Email created from pull request 28 (lumag:ipsec)
 ** https://github.com/Linaro/odp/pull/28
 ** Patch: https://github.com/Linaro/odp/pull/28.patch
 ** Base sha: 900dd9e2d3d2ae751ab2bc4e11dbd48ea7ed7030
 ** Merge commit sha: 1589f97414ab144b3cb1e65667d311783fdba670
 **/
 platform/linux-generic/odp_crypto.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/platform/linux-generic/odp_crypto.c b/platform/linux-generic/odp_crypto.c
index a0f3f7e..dfeb9f3 100644
--- a/platform/linux-generic/odp_crypto.c
+++ b/platform/linux-generic/odp_crypto.c
@@ -682,6 +682,7 @@  odp_crypto_session_create(odp_crypto_session_param_t *param,
 	if (session->p.iv.data) {
 		if (session->p.iv.length > MAX_IV_LEN) {
 			ODP_DBG("Maximum IV length exceeded\n");
+			free_session(session);
 			return -1;
 		}
 
@@ -732,6 +733,7 @@  odp_crypto_session_create(odp_crypto_session_param_t *param,
 	/* Check result */
 	if (rc) {
 		*status = ODP_CRYPTO_SES_CREATE_ERR_INV_CIPHER;
+		free_session(session);
 		return -1;
 	}
 
@@ -778,6 +780,7 @@  odp_crypto_session_create(odp_crypto_session_param_t *param,
 	/* Check result */
 	if (rc) {
 		*status = ODP_CRYPTO_SES_CREATE_ERR_INV_AUTH;
+		free_session(session);
 		return -1;
 	}