* [PATCH] crypto: inside-secure - Fix the return value of safexcel_xcbcmac_cra_init()
@ 2024-10-31 11:27 Li Huafei
2024-11-05 16:00 ` Antoine Tenart
2024-11-10 3:55 ` Herbert Xu
0 siblings, 2 replies; 4+ messages in thread
From: Li Huafei @ 2024-10-31 11:27 UTC (permalink / raw)
To: pliem, atenart, herbert, davem; +Cc: linux-crypto, linux-kernel, lihuafei1
The commit 320406cb60b6 ("crypto: inside-secure - Replace generic aes
with libaes") replaced crypto_alloc_cipher() with kmalloc(), but did not
modify the handling of the return value. When kmalloc() returns NULL,
PTR_ERR_OR_ZERO(NULL) returns 0, but in fact, the memory allocation has
failed, and -ENOMEM should be returned.
Fixes: 320406cb60b6 ("crypto: inside-secure - Replace generic aes with libaes")
Signed-off-by: Li Huafei <lihuafei1@huawei.com>
---
drivers/crypto/inside-secure/safexcel_hash.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/crypto/inside-secure/safexcel_hash.c b/drivers/crypto/inside-secure/safexcel_hash.c
index e17577b785c3..f44c08f5f5ec 100644
--- a/drivers/crypto/inside-secure/safexcel_hash.c
+++ b/drivers/crypto/inside-secure/safexcel_hash.c
@@ -2093,7 +2093,7 @@ static int safexcel_xcbcmac_cra_init(struct crypto_tfm *tfm)
safexcel_ahash_cra_init(tfm);
ctx->aes = kmalloc(sizeof(*ctx->aes), GFP_KERNEL);
- return PTR_ERR_OR_ZERO(ctx->aes);
+ return ctx->aes == NULL ? -ENOMEM : 0;
}
static void safexcel_xcbcmac_cra_exit(struct crypto_tfm *tfm)
--
2.25.1
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] crypto: inside-secure - Fix the return value of safexcel_xcbcmac_cra_init()
2024-10-31 11:27 [PATCH] crypto: inside-secure - Fix the return value of safexcel_xcbcmac_cra_init() Li Huafei
@ 2024-11-05 16:00 ` Antoine Tenart
2024-11-07 1:18 ` Li Huafei
2024-11-10 3:55 ` Herbert Xu
1 sibling, 1 reply; 4+ messages in thread
From: Antoine Tenart @ 2024-11-05 16:00 UTC (permalink / raw)
To: Li Huafei, davem, herbert, pliem; +Cc: linux-crypto, linux-kernel, lihuafei1
Quoting Li Huafei (2024-10-31 12:27:55)
> The commit 320406cb60b6 ("crypto: inside-secure - Replace generic aes
> with libaes") replaced crypto_alloc_cipher() with kmalloc(), but did not
> modify the handling of the return value. When kmalloc() returns NULL,
> PTR_ERR_OR_ZERO(NULL) returns 0, but in fact, the memory allocation has
> failed, and -ENOMEM should be returned.
>
> Fixes: 320406cb60b6 ("crypto: inside-secure - Replace generic aes with libaes")
> Signed-off-by: Li Huafei <lihuafei1@huawei.com>
Acked-by: Antoine Tenart <atenart@kernel.org>
Thanks!
> ---
> drivers/crypto/inside-secure/safexcel_hash.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/crypto/inside-secure/safexcel_hash.c b/drivers/crypto/inside-secure/safexcel_hash.c
> index e17577b785c3..f44c08f5f5ec 100644
> --- a/drivers/crypto/inside-secure/safexcel_hash.c
> +++ b/drivers/crypto/inside-secure/safexcel_hash.c
> @@ -2093,7 +2093,7 @@ static int safexcel_xcbcmac_cra_init(struct crypto_tfm *tfm)
>
> safexcel_ahash_cra_init(tfm);
> ctx->aes = kmalloc(sizeof(*ctx->aes), GFP_KERNEL);
> - return PTR_ERR_OR_ZERO(ctx->aes);
> + return ctx->aes == NULL ? -ENOMEM : 0;
> }
>
> static void safexcel_xcbcmac_cra_exit(struct crypto_tfm *tfm)
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] crypto: inside-secure - Fix the return value of safexcel_xcbcmac_cra_init()
2024-11-05 16:00 ` Antoine Tenart
@ 2024-11-07 1:18 ` Li Huafei
0 siblings, 0 replies; 4+ messages in thread
From: Li Huafei @ 2024-11-07 1:18 UTC (permalink / raw)
To: Antoine Tenart, davem, herbert, pliem; +Cc: linux-crypto, linux-kernel
On 2024/11/6 0:00, Antoine Tenart wrote:
> Quoting Li Huafei (2024-10-31 12:27:55)
>> The commit 320406cb60b6 ("crypto: inside-secure - Replace generic aes
>> with libaes") replaced crypto_alloc_cipher() with kmalloc(), but did not
>> modify the handling of the return value. When kmalloc() returns NULL,
>> PTR_ERR_OR_ZERO(NULL) returns 0, but in fact, the memory allocation has
>> failed, and -ENOMEM should be returned.
>>
>> Fixes: 320406cb60b6 ("crypto: inside-secure - Replace generic aes with libaes")
>> Signed-off-by: Li Huafei <lihuafei1@huawei.com>
>
> Acked-by: Antoine Tenart <atenart@kernel.org>
>
> Thanks!
>
Thank you for reviewing.
>> ---
>> drivers/crypto/inside-secure/safexcel_hash.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/crypto/inside-secure/safexcel_hash.c b/drivers/crypto/inside-secure/safexcel_hash.c
>> index e17577b785c3..f44c08f5f5ec 100644
>> --- a/drivers/crypto/inside-secure/safexcel_hash.c
>> +++ b/drivers/crypto/inside-secure/safexcel_hash.c
>> @@ -2093,7 +2093,7 @@ static int safexcel_xcbcmac_cra_init(struct crypto_tfm *tfm)
>>
>> safexcel_ahash_cra_init(tfm);
>> ctx->aes = kmalloc(sizeof(*ctx->aes), GFP_KERNEL);
>> - return PTR_ERR_OR_ZERO(ctx->aes);
>> + return ctx->aes == NULL ? -ENOMEM : 0;
>> }
>>
>> static void safexcel_xcbcmac_cra_exit(struct crypto_tfm *tfm)
>> --
>> 2.25.1
>>
> .
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] crypto: inside-secure - Fix the return value of safexcel_xcbcmac_cra_init()
2024-10-31 11:27 [PATCH] crypto: inside-secure - Fix the return value of safexcel_xcbcmac_cra_init() Li Huafei
2024-11-05 16:00 ` Antoine Tenart
@ 2024-11-10 3:55 ` Herbert Xu
1 sibling, 0 replies; 4+ messages in thread
From: Herbert Xu @ 2024-11-10 3:55 UTC (permalink / raw)
To: Li Huafei; +Cc: pliem, atenart, davem, linux-crypto, linux-kernel
On Thu, Oct 31, 2024 at 07:27:55PM +0800, Li Huafei wrote:
> The commit 320406cb60b6 ("crypto: inside-secure - Replace generic aes
> with libaes") replaced crypto_alloc_cipher() with kmalloc(), but did not
> modify the handling of the return value. When kmalloc() returns NULL,
> PTR_ERR_OR_ZERO(NULL) returns 0, but in fact, the memory allocation has
> failed, and -ENOMEM should be returned.
>
> Fixes: 320406cb60b6 ("crypto: inside-secure - Replace generic aes with libaes")
> Signed-off-by: Li Huafei <lihuafei1@huawei.com>
> ---
> drivers/crypto/inside-secure/safexcel_hash.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Patch applied. 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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-11-10 3:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-31 11:27 [PATCH] crypto: inside-secure - Fix the return value of safexcel_xcbcmac_cra_init() Li Huafei
2024-11-05 16:00 ` Antoine Tenart
2024-11-07 1:18 ` Li Huafei
2024-11-10 3:55 ` Herbert Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®