]> git.baikalelectronics.ru Git - kernel.git/commit
crypto: ccp - fix resource leaks in ccp_run_aes_gcm_cmd()
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 26 Aug 2021 13:04:27 +0000 (16:04 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 6 Oct 2021 13:42:39 +0000 (15:42 +0200)
commitc76a65f19950d94a60bb890911e3dbdf3143908f
tree25e230ae6679de51e0fadfcc7b02f0cd4d7b0acc
parent37e69919f967ae30de20d7c5d8a90204199d6419
crypto: ccp - fix resource leaks in ccp_run_aes_gcm_cmd()

commit 505d9dcb0f7ddf9d075e729523a33d38642ae680 upstream.

There are three bugs in this code:

1) If we ccp_init_data() fails for &src then we need to free aad.
   Use goto e_aad instead of goto e_ctx.
2) The label to free the &final_wa was named incorrectly as "e_tag" but
   it should have been "e_final_wa".  One error path leaked &final_wa.
3) The &tag was leaked on one error path.  In that case, I added a free
   before the goto because the resource was local to that block.

Fixes: 48c4c7bda886 ("crypto: ccp - Enable support for AES GCM on v5 CCPs")
Reported-by: "minihanshen(沈明航)" <minihanshen@tencent.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: John Allen <john.allen@amd.com>
Tested-by: John Allen <john.allen@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/crypto/ccp/ccp-ops.c