From: Nathan Chancellor <nathan@kernel.org>
To: Alexander Potapenko <glider@google.com>, Marco Elver <elver@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>,
kasan-dev@googlegroups.com, linux-mm@kvack.org,
llvm@lists.linux.dev
Subject: clang-22 -Walloc-size in mm/kfence/kfence_test.c in 6.6 and 6.1
Date: Tue, 2 Sep 2025 17:07:52 -0700 [thread overview]
Message-ID: <20250903000752.GA2403288@ax162> (raw)
Hi kfence folks,
After [1] in clang, I am seeing an instance of this pop up in
mm/kfence/kfence_test.c on linux-6.6.y and linux-6.1.y:
mm/kfence/kfence_test.c:723:8: error: allocation of insufficient size '0' for type 'char' with size '1' [-Werror,-Walloc-size]
723 | buf = krealloc(buf, 0, GFP_KERNEL); /* Free. */
| ^
I do not see this in linux-6.12.y or newer but I wonder if that is just
because the memory allocation profiling adds some indirection that makes
it harder for clang to perform this analysis?
Should this warning just be silenced for this translation unit or is
there some other fix that could be done here?
[1]: https://github.com/llvm/llvm-project/commit/6dc188d4eb15cbe9bdece3d940f03d93b926328c
Cheers,
Nathan
next reply other threads:[~2025-09-03 0:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-03 0:07 Nathan Chancellor [this message]
2025-09-03 3:40 ` clang-22 -Walloc-size in mm/kfence/kfence_test.c in 6.6 and 6.1 Matthew Wilcox
2025-09-03 6:00 ` Marco Elver
2025-09-03 18:48 ` Nathan Chancellor
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=20250903000752.GA2403288@ax162 \
--to=nathan@kernel.org \
--cc=dvyukov@google.com \
--cc=elver@google.com \
--cc=glider@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-mm@kvack.org \
--cc=llvm@lists.linux.dev \
/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;
as well as URLs for NNTP newsgroup(s).