All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kallsyms: use kmalloc_array() instead of kmalloc()
@ 2025-09-22 11:34 Sahil Chandna
  0 siblings, 0 replies; 2+ messages in thread
From: Sahil Chandna @ 2025-09-22 11:34 UTC (permalink / raw)
  To: frederic, linux-kernel; +Cc: chandna.linuxkernel

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.
kallsyms: Replace kmalloc with kmalloc_array

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.51.0


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

* [PATCH] kallsyms: use kmalloc_array() instead of kmalloc()
@ 2025-09-26  7:50 Sahil Chandna
  0 siblings, 0 replies; 2+ messages in thread
From: Sahil Chandna @ 2025-09-26  7:50 UTC (permalink / raw)
  To: akpm, linux-kernel; +Cc: skhan, david.hunter.linux, Sahil Chandna

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


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

end of thread, other threads:[~2025-09-26  7:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-22 11:34 [PATCH] kallsyms: use kmalloc_array() instead of kmalloc() Sahil Chandna
  -- strict thread matches above, loose matches on Subject: below --
2025-09-26  7:50 Sahil Chandna

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.