Skip to content

Commit ce8fd05

Browse files
Bartosz Golaszewskiherbertx
authored andcommitted
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 <[email protected]> Reviewed-by: Neil Armstrong <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent c151535 commit ce8fd05

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/crypto/qce/sha.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright (c) 2010-2014, The Linux Foundation. All rights reserved.
44
*/
55

6+
#include <linux/cleanup.h>
67
#include <linux/device.h>
78
#include <linux/dma-mapping.h>
89
#include <linux/interrupt.h>
@@ -336,7 +337,6 @@ static int qce_ahash_hmac_setkey(struct crypto_ahash *tfm, const u8 *key,
336337
struct scatterlist sg;
337338
unsigned int blocksize;
338339
struct crypto_ahash *ahash_tfm;
339-
u8 *buf;
340340
int ret;
341341
const char *alg_name;
342342

@@ -370,7 +370,8 @@ static int qce_ahash_hmac_setkey(struct crypto_ahash *tfm, const u8 *key,
370370
crypto_req_done, &wait);
371371
crypto_ahash_clear_flags(ahash_tfm, ~0);
372372

373-
buf = kzalloc(keylen + QCE_MAX_ALIGN_SIZE, GFP_KERNEL);
373+
u8 *buf __free(kfree) = kzalloc(keylen + QCE_MAX_ALIGN_SIZE,
374+
GFP_KERNEL);
374375
if (!buf) {
375376
ret = -ENOMEM;
376377
goto err_free_req;
@@ -382,7 +383,6 @@ static int qce_ahash_hmac_setkey(struct crypto_ahash *tfm, const u8 *key,
382383

383384
ret = crypto_wait_req(crypto_ahash_digest(req), &wait);
384385

385-
kfree(buf);
386386
err_free_req:
387387
ahash_request_free(req);
388388
err_free_ahash:

0 commit comments

Comments
 (0)