From: Matthew Wilcox <willy@infradead.org>
To: Ethan Carter Edwards <ethan@ethancedwards.com>
Cc: Theodore Ts'o <tytso@mit.edu>,
Andreas Dilger <adilger.kernel@dilger.ca>,
linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH] ext4: hash: change kzalloc(n * sizeof, ...) to kcalloc(n, sizeof, ...)
Date: Sun, 16 Mar 2025 03:28:41 +0000 [thread overview]
Message-ID: <Z9ZFabmQuSLiwfE5@casper.infradead.org> (raw)
In-Reply-To: <20250315-ext4-hash-kcalloc-v1-1-a9132cb49276@ethancedwards.com>
On Sat, Mar 15, 2025 at 12:29:34PM -0400, Ethan Carter Edwards wrote:
> Open coded arithmetic in allocator arguments is discouraged. Helper
> functions like kcalloc are preferred.
Well, yes, but ...
> +++ 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);
sizeof(char) is defined to be 1. So this should just be
kzalloc(PATH_MAX, GFP_KERNEL).
next prev parent reply other threads:[~2025-03-16 3:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2025-03-16 5:27 ` Andreas Dilger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z9ZFabmQuSLiwfE5@casper.infradead.org \
--to=willy@infradead.org \
--cc=adilger.kernel@dilger.ca \
--cc=ethan@ethancedwards.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox