kallsyms: use kmalloc_array() instead of kmalloc()
PATCH 1/1 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.
kallsyms: Replace kmalloc with kmalloc_array
Signed-off-by Sahil Chandna <[email protected]>
--- kernel/kallsyms_selftest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/kallsyms_selftest.c +1 -1
@@ -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 ;
Signature · 1 line
2.51.0