diff mbox series

[API-NEXT,v5,7/11] linux-generic: crypto: don't leak sessions if creation fails

Message ID 1494950422-11135-8-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [API-NEXT,v5,1/11] api: ipsec: add soft limit expiration event | expand

Commit Message

Github ODP bot May 16, 2017, 4 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: f4c213cccc49b4b28557506ad19fba49b872d24f
 ** Merge commit sha: e6ef5a70e5261ee32e5edb33fc7710d103010d95
 **/
 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;
 	}