From: Sahil Chandna <chandna.linuxkernel@gmail.com>
To: akpm@linux-foundation.org, linux-kernel@vger.kernel.org
Cc: skhan@linuxfoundation.org, david.hunter.linux@gmail.com,
Sahil Chandna <chandna.linuxkernel@gmail.com>
Subject: [PATCH] kallsyms: use kmalloc_array() instead of kmalloc()
Date: Fri, 26 Sep 2025 13:20:53 +0530 [thread overview]
Message-ID: <20250926075053.25615-1-chandna.linuxkernel@gmail.com> (raw)
Replace kmalloc(sizeof(*stat) * 2, GFP_KERNEL) with
kmalloc_array(2, sizeof(*stat), GFP_KERNEL) to prevent potential
overflow, as recommended in Documentation/process/deprecated.rst.
Signed-off-by: Sahil Chandna <chandna.linuxkernel@gmail.com>
---
kernel/kallsyms_selftest.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/kallsyms_selftest.c b/kernel/kallsyms_selftest.c
index cf4af5728307..2b082a7e24a2 100644
--- a/kernel/kallsyms_selftest.c
+++ b/kernel/kallsyms_selftest.c
@@ -264,7 +264,7 @@ static int test_kallsyms_basic_function(void)
char namebuf[KSYM_NAME_LEN];
struct test_stat *stat, *stat2;
- stat = kmalloc(sizeof(*stat) * 2, GFP_KERNEL);
+ stat = kmalloc_array(2, sizeof(*stat), GFP_KERNEL);
if (!stat)
return -ENOMEM;
stat2 = stat + 1;
--
2.50.1
next reply other threads:[~2025-09-26 7:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-26 7:50 Sahil Chandna [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-09-22 11:34 [PATCH] kallsyms: use kmalloc_array() instead of kmalloc() Sahil Chandna
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=20250926075053.25615-1-chandna.linuxkernel@gmail.com \
--to=chandna.linuxkernel@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=david.hunter.linux@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=skhan@linuxfoundation.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.