Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bpf: Switch to krealloc_array()

Let the krealloc_array() copy the original data and
check for a multiplication overflow.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/bpf/20240429120005.3539116-1-andriy.shevchenko@linux.intel.com

authored by

Andy Shevchenko and committed by
Andrii Nakryiko
a3034872 cb01621b

+1 -1
+1 -1
kernel/bpf/core.c
··· 850 850 return -EINVAL; 851 851 } 852 852 853 - tab = krealloc(tab, size * sizeof(*poke), GFP_KERNEL); 853 + tab = krealloc_array(tab, size, sizeof(*poke), GFP_KERNEL); 854 854 if (!tab) 855 855 return -ENOMEM; 856 856