summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>2024-12-03 10:19:35 +0100
committerHerbert Xu <herbert@gondor.apana.org.au>2024-12-14 17:21:43 +0800
commitce8fd0500b741b3669c246cc604f1f2343cdd6fd (patch)
treea4a58cad1a381169b9abd4354a8e5d7c835c0785
parentc151535cf46fd0b6cc34884762dd1610c628bac1 (diff)
downloadlinux-stable-ce8fd0500b741b3669c246cc604f1f2343cdd6fd.tar.gz
linux-stable-ce8fd0500b741b3669c246cc604f1f2343cdd6fd.tar.bz2
linux-stable-ce8fd0500b741b3669c246cc604f1f2343cdd6fd.zip
crypto: qce - use __free() for a buffer that's always freed
The buffer allocated in qce_ahash_hmac_setkey is always freed before returning to use __free() to automate it. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--drivers/crypto/qce/sha.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/crypto/qce/sha.c b/drivers/crypto/qce/sha.c
index fc72af8aa9a7..916908c04b63 100644
--- a/drivers/crypto/qce/sha.c
+++ b/drivers/crypto/qce/sha.c
@@ -3,6 +3,7 @@
* Copyright (c) 2010-2014, The Linux Foundation. All rights reserved.
*/
+#include <linux/cleanup.h>
#include <linux/device.h>
#include <linux/dma-mapping.h>
#include <linux/interrupt.h>
@@ -336,7 +337,6 @@ static int qce_ahash_hmac_setkey(struct crypto_ahash *tfm, const u8 *key,
struct scatterlist sg;
unsigned int blocksize;
struct crypto_ahash *ahash_tfm;
- u8 *buf;
int ret;
const char *alg_name;
@@ -370,7 +370,8 @@ static int qce_ahash_hmac_setkey(struct crypto_ahash *tfm, const u8 *key,
crypto_req_done, &wait);
crypto_ahash_clear_flags(ahash_tfm, ~0);
- buf = kzalloc(keylen + QCE_MAX_ALIGN_SIZE, GFP_KERNEL);
+ u8 *buf __free(kfree) = kzalloc(keylen + QCE_MAX_ALIGN_SIZE,
+ GFP_KERNEL);
if (!buf) {
ret = -ENOMEM;
goto err_free_req;
@@ -382,7 +383,6 @@ static int qce_ahash_hmac_setkey(struct crypto_ahash *tfm, const u8 *key,
ret = crypto_wait_req(crypto_ahash_digest(req), &wait);
- kfree(buf);
err_free_req:
ahash_request_free(req);
err_free_ahash: