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

Configure Feed

Select the types of activity you want to include in your feed.

Input: wistron_btns - use kmemdup_array instead of kmemdup for multiple allocation

Let the kmemdup_array() take care about multiplication
and possible overflows.

Using kmemdup_array() is more appropriate and makes the code
easier to audit.

Signed-off-by: Shen Lichuan <shenlichuan@vivo.com>
Link: https://lore.kernel.org/r/20240826045253.3503-1-shenlichuan@vivo.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

authored by

Shen Lichuan and committed by
Dmitry Torokhov
b7ffc98a 6994d8b8

+2 -2
+2 -2
drivers/input/misc/wistron_btns.c
··· 990 990 for (key = keymap; key->type != KE_END; key++) 991 991 length++; 992 992 993 - new_keymap = kmemdup(keymap, length * sizeof(struct key_entry), 994 - GFP_KERNEL); 993 + new_keymap = kmemdup_array(keymap, length, sizeof(struct key_entry), 994 + GFP_KERNEL); 995 995 if (!new_keymap) 996 996 return -ENOMEM; 997 997