Skip to content

Commit 94b3f02

Browse files
Sahil Chandnaakpm00
authored andcommitted
kallsyms: use kmalloc_array() instead of kmalloc()
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. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Sahil Chandna <[email protected]> Cc: Shuah Khan <[email protected]> Cc: David Hunter <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent cf1bb6b commit 94b3f02

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/kallsyms_selftest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ static int test_kallsyms_basic_function(void)
264264
char namebuf[KSYM_NAME_LEN];
265265
struct test_stat *stat, *stat2;
266266

267-
stat = kmalloc(sizeof(*stat) * 2, GFP_KERNEL);
267+
stat = kmalloc_array(2, sizeof(*stat), GFP_KERNEL);
268268
if (!stat)
269269
return -ENOMEM;
270270
stat2 = stat + 1;

0 commit comments

Comments
 (0)