crypto: ccp - release hmac_buf if ccp_run_sha_cmd fails
Subsystems (2)
PATCH 1/1 crypto: ccp - release hmac_buf if ccp_run_sha_cmd fails
In ccp_run_sha_cmd, if the type of sha is invalid, the allocated hmac_buf should be released.
--- drivers/crypto/ccp/ccp-ops.c | 1 + 1 file changed, 1 insertion(+)
drivers/crypto/ccp/ccp-ops.c +1 -0
@@ -1782,6 +1782,7 @@ 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; }
Signature · 1 line
2.17.1
Lendacky, Thomas
maintainerQuoted 13 lines · Navid Emamdoost
In
ccp_run_sha_cmd, if the type of sha is invalid, the allocatedhmac_bufshould be released.Signed-off-by Navid Emamdoost <[email protected]>--- drivers/crypto/ccp/ccp-ops.c | 1 + 1 file changed, 1 insertion(+)drivers/crypto/ccp/ccp-ops.c +0
-0
drivers/crypto/ccp/ccp-ops.c static int ccp_run_sha_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) · line 1785
Quoted 4 lines
drivers/crypto/ccp/ccp-ops.c +1
-0@@ -1782,6 +1782,7 @@ static int ccp_run_sha_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) LSB_ITEM_SIZE);break ;default : +kfree (hmac_buf);
Well, theoretically we can never reach this section since the routine would have never proceeded past the first switch statement at the beginning of the function. But, if the code is ever modified and some of the switch statements missed then it's possible...
drivers/crypto/ccp/ccp-ops.c static int ccp_run_sha_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) · line 1787
Quoted 2 lines
drivers/crypto/ccp/ccp-ops.c +0
-0ret = -EINVAL ; goto e_ctx;
I know it's not part of your change, but this looks like it should be goto e_data instead of e_ctx, too.
Thanks,
Tom
Quoted 2 lines
drivers/crypto/ccp/ccp-ops.c +0
-0}
Quoted 23 lines · Thomas
Quoted 13 lines · Navid Emamdoost
In
ccp_run_sha_cmd, if the type of sha is invalid, the allocatedhmac_bufshould be released.Signed-off-by Navid Emamdoost <[email protected]>--- drivers/crypto/ccp/ccp-ops.c | 1 + 1 file changed, 1 insertion(+)drivers/crypto/ccp/ccp-ops.c +0
-0drivers/crypto/ccp/ccp-ops.c static int ccp_run_sha_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) · line 1785
Quoted 4 lines
drivers/crypto/ccp/ccp-ops.c +1
-0@@ -1782,6 +1782,7 @@ static int ccp_run_sha_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) LSB_ITEM_SIZE);break ;default : +kfree (hmac_buf);Well, theoretically we can never reach this section since the routine would have never proceeded past the first switch statement at the beginning of the function. But, if the code is ever modified and some of the switch statements missed then it's possible...
Quoted 4 lines
drivers/crypto/ccp/ccp-ops.c static int ccp_run_sha_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) · line 1787
Quoted 2 lines
drivers/crypto/ccp/ccp-ops.c +0
-0ret = -EINVAL ; goto e_ctx;I know it's not part of your change, but this looks like it should be goto
e_datainstead ofe_ctx, too.
I agree with this. Please resubmit with the suggested change, and use a commit message along the the lines of
crypto: ccp - Release all allocated memory if sha type is invalid
Gary
PATCH v2 1/1 crypto: ccp - Release all allocated memory if sha type is invalid
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.
--- drivers/crypto/ccp/ccp-ops.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/crypto/ccp/ccp-ops.c +2 -1
@@ -1782,8 +1782,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));
Signature · 1 line
2.17.1
Re: [PATCH v2] crypto: ccp - Release all allocated memory if sha type is invalid
Quoted 7 lines · Navid Emamdoost
Release all allocated memory if sha type is invalid:
Inccp_run_sha_cmd, if the type of sha is invalid, the allocatedhmac_bufshould be released.v2: fix the goto.
Signed-off-by Navid Emamdoost <[email protected]>
Quoted 19 lines
--- drivers/crypto/ccp/ccp-ops.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/crypto/ccp/ccp-ops.c +2
-1@@ -1782,8 +1782,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));
Herbert Xu
maintainerRe: [PATCH v2] crypto: ccp - Release all allocated memory if sha type is invalid
In reply to Navid EmamdoostQuoted 10 lines · Navid Emamdoost
Release all allocated memory if sha type is invalid:
Inccp_run_sha_cmd, if the type of sha is invalid, the allocatedhmac_bufshould be released.v2: fix the goto.
Signed-off-by Navid Emamdoost <[email protected]>--- drivers/crypto/ccp/ccp-ops.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt