]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
crypto: ccp - Release all allocated memory if sha type is invalid
authorNavid Emamdoost <navid.emamdoost@gmail.com>
Thu, 19 Sep 2019 16:04:48 +0000 (11:04 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 5 Aug 2020 08:05:59 +0000 (10:05 +0200)
[ Upstream commit 128c66429247add5128c03dc1e144ca56f05a4e2 ]

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: Sasha Levin <sashal@kernel.org>
drivers/crypto/ccp/ccp-ops.c

index 330853a2702f027ac82b5bab4a098ab4f2e8d0d7..43b74cf0787e12b50204540be1eb572ec42d45cd 100644 (file)
@@ -1783,8 +1783,9 @@ 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));