| From 8503f31fed01f742acaefc32d9bcf14a6c641276 Mon Sep 17 00:00:00 2001 |
| From: Navid Emamdoost <navid.emamdoost@gmail.com> |
| Date: Thu, 19 Sep 2019 11:04:48 -0500 |
| Subject: [PATCH] crypto: ccp - Release all allocated memory if sha type is |
| invalid |
| |
| commit 128c66429247add5128c03dc1e144ca56f05a4e2 upstream. |
| |
| Release all allocated memory if sha type is invalid: |
| In ccp_run_sha_cmd, if the type of sha is invalid, the allocated |
| hmac_buf should be released. |
| |
| v2: fix the goto. |
| |
| Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com> |
| Acked-by: Gary R Hook <gary.hook@amd.com> |
| Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> |
| Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> |
| |
| diff --git a/drivers/crypto/ccp/ccp-ops.c b/drivers/crypto/ccp/ccp-ops.c |
| index a13e8a362316..e12506c93a52 100644 |
| --- a/drivers/crypto/ccp/ccp-ops.c |
| +++ b/drivers/crypto/ccp/ccp-ops.c |
| @@ -1790,8 +1790,9 @@ static int ccp_run_sha_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) |
| LSB_ITEM_SIZE); |
| break; |
| default: |
| + kfree(hmac_buf); |
| ret = -EINVAL; |
| - goto e_ctx; |
| + goto e_data; |
| } |
| |
| memset(&hmac_cmd, 0, sizeof(hmac_cmd)); |
| -- |
| 2.7.4 |
| |