public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ext4: hash: change kzalloc(n * sizeof, ...) to kcalloc(n, sizeof, ...)
@ 2025-03-15 16:29 Ethan Carter Edwards
  2025-03-16  3:28 ` Matthew Wilcox
  0 siblings, 1 reply; 3+ messages in thread
From: Ethan Carter Edwards @ 2025-03-15 16:29 UTC (permalink / raw)
  To: Theodore Ts'o, Andreas Dilger
  Cc: linux-ext4, linux-kernel, linux-fsdevel, linux-hardening,
	Ethan Carter Edwards

Open coded arithmetic in allocator arguments is discouraged. Helper
functions like kcalloc are preferred.

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments

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

diff --git a/fs/ext4/hash.c b/fs/ext4/hash.c
index deabe29da7fbc3d35f674ff861a2f3b579ffdea2..7a9afac1597c69f319f02bb816ca797d32c188ca 100644
--- a/fs/ext4/hash.c
+++ b/fs/ext4/hash.c
@@ -302,7 +302,7 @@ int ext4fs_dirhash(const struct inode *dir, const char *name, int len,
 
 	if (len && IS_CASEFOLDED(dir) &&
 	   (!IS_ENCRYPTED(dir) || fscrypt_has_encryption_key(dir))) {
-		buff = kzalloc(sizeof(char) * PATH_MAX, GFP_KERNEL);
+		buff = kcalloc(PATH_MAX, sizeof(char), GFP_KERNEL);
 		if (!buff)
 			return -ENOMEM;
 

---
base-commit: da920b7df701770e006928053672147075587fb2
change-id: 20250315-ext4-hash-kcalloc-203033977bd9

Best regards,
-- 
Ethan Carter Edwards <ethan@ethancedwards.com>


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

end of thread, other threads:[~2025-03-16  5:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-15 16:29 [PATCH] ext4: hash: change kzalloc(n * sizeof, ...) to kcalloc(n, sizeof, ...) Ethan Carter Edwards
2025-03-16  3:28 ` Matthew Wilcox
2025-03-16  5:27   ` Andreas Dilger

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