Pablo Greco d6c4c4
From 128c66429247add5128c03dc1e144ca56f05a4e2 Mon Sep 17 00:00:00 2001
Pablo Greco d6c4c4
From: Navid Emamdoost <navid.emamdoost@gmail.com>
Pablo Greco d6c4c4
Date: Thu, 19 Sep 2019 11:04:48 -0500
Pablo Greco d6c4c4
Subject: [PATCH] crypto: ccp - Release all allocated memory if sha type is
Pablo Greco d6c4c4
 invalid
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Release all allocated memory if sha type is invalid:
Pablo Greco d6c4c4
In ccp_run_sha_cmd, if the type of sha is invalid, the allocated
Pablo Greco d6c4c4
hmac_buf should be released.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
v2: fix the goto.
Pablo Greco d6c4c4
Pablo Greco d6c4c4
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Pablo Greco d6c4c4
Acked-by: Gary R Hook <gary.hook@amd.com>
Pablo Greco d6c4c4
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Pablo Greco d6c4c4
---
Pablo Greco d6c4c4
 drivers/crypto/ccp/ccp-ops.c | 3 ++-
Pablo Greco d6c4c4
 1 file changed, 2 insertions(+), 1 deletion(-)
Pablo Greco d6c4c4
Pablo Greco d6c4c4
diff --git a/drivers/crypto/ccp/ccp-ops.c b/drivers/crypto/ccp/ccp-ops.c
Pablo Greco d6c4c4
index c8da8eb160da..422193690fd4 100644
Pablo Greco d6c4c4
--- a/drivers/crypto/ccp/ccp-ops.c
Pablo Greco d6c4c4
+++ b/drivers/crypto/ccp/ccp-ops.c
Pablo Greco d6c4c4
@@ -1777,8 +1777,9 @@ ccp_run_sha_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd)
Pablo Greco d6c4c4
 			       LSB_ITEM_SIZE);
Pablo Greco d6c4c4
 			break;
Pablo Greco d6c4c4
 		default:
Pablo Greco d6c4c4
+			kfree(hmac_buf);
Pablo Greco d6c4c4
 			ret = -EINVAL;
Pablo Greco d6c4c4
-			goto e_ctx;
Pablo Greco d6c4c4
+			goto e_data;
Pablo Greco d6c4c4
 		}
Pablo Greco d6c4c4
Pablo Greco d6c4c4
 		memset(&hmac_cmd, 0, sizeof(hmac_cmd));
Pablo Greco d6c4c4
-- 
Pablo Greco d6c4c4
2.23.0
Pablo Greco d6c4c4