lkml.org 
[lkml]   [2022]   [Mar]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v1] crypto: stm32: Check for NULL return of kmalloc_array()
QintaoShen <unSimple1993@163.com> wrote:
> As the potential failure of memory allocation, kmalloc_array() may return
> NULL and lead to NULL pointer dereference because of the usage of 'rctx->hw_context'.
>
> Therefore, it is better to check the return value of kmalloc_array().
>
> Signed-off-by: QintaoShen <unSimple1993@163.com>
> ---
> drivers/crypto/stm32/stm32-hash.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/crypto/stm32/stm32-hash.c b/drivers/crypto/stm32/stm32-hash.c
> index d33006d..f1a1a13 100644
> --- a/drivers/crypto/stm32/stm32-hash.c
> +++ b/drivers/crypto/stm32/stm32-hash.c
> @@ -970,7 +970,8 @@ static int stm32_hash_export(struct ahash_request *req, void *out)
> rctx->hw_context = kmalloc_array(3 + HASH_CSR_REGISTER_NUMBER,
> sizeof(u32),
> GFP_KERNEL);
> -
> + if (!rctx->hw_context)
> + return -ENOMEM;

This patch introduces a runtime PM imbalance. Please fix.

Thanks,
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

\
 
 \ /
  Last update: 2022-03-25 05:17    [W:0.032 / U:0.140 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site