mirror of https://github.com/torvalds/linux.git
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/20250926075053.25615-1-chandna.linuxkernel@gmail.com Signed-off-by: Sahil Chandna <chandna.linuxkernel@gmail.com> Cc: Shuah Khan <shuah@kernel.org> Cc: David Hunter <david.hunter.linux@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
cf1bb6b2d0
commit
94b3f02fb3
|
|
@ -264,7 +264,7 @@ static int test_kallsyms_basic_function(void)
|
||||||
char namebuf[KSYM_NAME_LEN];
|
char namebuf[KSYM_NAME_LEN];
|
||||||
struct test_stat *stat, *stat2;
|
struct test_stat *stat, *stat2;
|
||||||
|
|
||||||
stat = kmalloc(sizeof(*stat) * 2, GFP_KERNEL);
|
stat = kmalloc_array(2, sizeof(*stat), GFP_KERNEL);
|
||||||
if (!stat)
|
if (!stat)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
stat2 = stat + 1;
|
stat2 = stat + 1;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue