mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] fs: erofs: xattr.c change kzalloc to kcalloc
@ 2024-12-23  3:00 Ethan Carter Edwards
  2024-12-23  3:32 ` Gao Xiang
  0 siblings, 1 reply; 3+ messages in thread
From: Ethan Carter Edwards @ 2024-12-23  3:00 UTC (permalink / raw)
  To: xiang; +Cc: zbestahu, linux-erofs, linux-kernel

From 272d7ef4611e64269fada0ea3021eece590118b9 Mon Sep 17 00:00:00 2001
From: Ethan Carter Edwards <ethan@ethancedwards.com>
Date: Sun, 22 Dec 2024 21:23:56 -0500
Subject: [PATCH] fs: erofs: xattr.c change kzalloc to kcalloc

Refactor xattr.c to use kcalloc instead of kzalloc when multiplying
allocation size by count. This refactor prevents unintentional
memory overflows. Discovered by checkpatch.pl.

Signed-off-by: Ethan Carter Edwards <ethan@ethancedwards.com>
---
 fs/erofs/xattr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/erofs/xattr.c b/fs/erofs/xattr.c
index a90d7d649739..7940241d9355 100644
--- a/fs/erofs/xattr.c
+++ b/fs/erofs/xattr.c
@@ -478,7 +478,7 @@ int erofs_xattr_prefixes_init(struct super_block *sb)
 	if (!sbi->xattr_prefix_count)
 		return 0;
 
-	pfs = kzalloc(sbi->xattr_prefix_count * sizeof(*pfs), GFP_KERNEL);
+	pfs = kcalloc(sbi->xattr_prefix_count, sizeof(*pfs), GFP_KERNEL);
 	if (!pfs)
 		return -ENOMEM;
 
-- 
2.47.1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] fs: erofs: xattr.c change kzalloc to kcalloc
  2024-12-23  3:00 [PATCH] fs: erofs: xattr.c change kzalloc to kcalloc Ethan Carter Edwards
@ 2024-12-23  3:32 ` Gao Xiang
  2025-01-16  7:42   ` Chao Yu
  0 siblings, 1 reply; 3+ messages in thread
From: Gao Xiang @ 2024-12-23  3:32 UTC (permalink / raw)
  To: Ethan Carter Edwards, xiang; +Cc: zbestahu, linux-erofs, linux-kernel



On 2024/12/23 11:00, Ethan Carter Edwards wrote:
>  From 272d7ef4611e64269fada0ea3021eece590118b9 Mon Sep 17 00:00:00 2001
> From: Ethan Carter Edwards <ethan@ethancedwards.com>
> Date: Sun, 22 Dec 2024 21:23:56 -0500
> Subject: [PATCH] fs: erofs: xattr.c change kzalloc to kcalloc
> 
> Refactor xattr.c to use kcalloc instead of kzalloc when multiplying
> allocation size by count. This refactor prevents unintentional
> memory overflows. Discovered by checkpatch.pl.
> 
> Signed-off-by: Ethan Carter Edwards <ethan@ethancedwards.com>

Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>

Although your raw patch format is incorrect.  You shouldn't
send the whole patch as the content, but just use
`git send-email` to send the patch.

I've fixed it up manually, no need to resend.

Thanks,
Gao Xiang

> ---
>   fs/erofs/xattr.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/erofs/xattr.c b/fs/erofs/xattr.c
> index a90d7d649739..7940241d9355 100644
> --- a/fs/erofs/xattr.c
> +++ b/fs/erofs/xattr.c
> @@ -478,7 +478,7 @@ int erofs_xattr_prefixes_init(struct super_block *sb)
>   	if (!sbi->xattr_prefix_count)
>   		return 0;
>   
> -	pfs = kzalloc(sbi->xattr_prefix_count * sizeof(*pfs), GFP_KERNEL);
> +	pfs = kcalloc(sbi->xattr_prefix_count, sizeof(*pfs), GFP_KERNEL);
>   	if (!pfs)
>   		return -ENOMEM;
>   


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] fs: erofs: xattr.c change kzalloc to kcalloc
  2024-12-23  3:32 ` Gao Xiang
@ 2025-01-16  7:42   ` Chao Yu
  0 siblings, 0 replies; 3+ messages in thread
From: Chao Yu @ 2025-01-16  7:42 UTC (permalink / raw)
  To: Gao Xiang, Ethan Carter Edwards, xiang; +Cc: chao, linux-erofs, linux-kernel

On 12/23/24 11:32, Gao Xiang wrote:
> On 2024/12/23 11:00, Ethan Carter Edwards wrote:
>>  From 272d7ef4611e64269fada0ea3021eece590118b9 Mon Sep 17 00:00:00 2001
>> From: Ethan Carter Edwards <ethan@ethancedwards.com>
>> Date: Sun, 22 Dec 2024 21:23:56 -0500
>> Subject: [PATCH] fs: erofs: xattr.c change kzalloc to kcalloc
>>
>> Refactor xattr.c to use kcalloc instead of kzalloc when multiplying
>> allocation size by count. This refactor prevents unintentional
>> memory overflows. Discovered by checkpatch.pl.
>>
>> Signed-off-by: Ethan Carter Edwards <ethan@ethancedwards.com>
> 
> Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-01-16  7:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-23  3:00 [PATCH] fs: erofs: xattr.c change kzalloc to kcalloc Ethan Carter Edwards
2024-12-23  3:32 ` Gao Xiang
2025-01-16  7:42   ` Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome