Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Bartosz Golaszewski and committed by
Herbert Xu
ce8fd050 c151535c

+3 -3
+3 -3
drivers/crypto/qce/sha.c
··· 3 3 * Copyright (c) 2010-2014, The Linux Foundation. All rights reserved. 4 4 */ 5 5 6 + #include <linux/cleanup.h> 6 7 #include <linux/device.h> 7 8 #include <linux/dma-mapping.h> 8 9 #include <linux/interrupt.h> ··· 337 336 struct scatterlist sg; 338 337 unsigned int blocksize; 339 338 struct crypto_ahash *ahash_tfm; 340 - u8 *buf; 341 339 int ret; 342 340 const char *alg_name; 343 341 ··· 370 370 crypto_req_done, &wait); 371 371 crypto_ahash_clear_flags(ahash_tfm, ~0); 372 372 373 - buf = kzalloc(keylen + QCE_MAX_ALIGN_SIZE, GFP_KERNEL); 373 + u8 *buf __free(kfree) = kzalloc(keylen + QCE_MAX_ALIGN_SIZE, 374 + GFP_KERNEL); 374 375 if (!buf) { 375 376 ret = -ENOMEM; 376 377 goto err_free_req; ··· 383 382 384 383 ret = crypto_wait_req(crypto_ahash_digest(req), &wait); 385 384 386 - kfree(buf); 387 385 err_free_req: 388 386 ahash_request_free(req); 389 387 err_free_ahash: