]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
Input: wistron_btns - use kmemdup_array instead of kmemdup for multiple allocation
authorShen Lichuan <shenlichuan@vivo.com>
Mon, 26 Aug 2024 04:52:53 +0000 (12:52 +0800)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 26 Aug 2024 17:22:00 +0000 (10:22 -0700)
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>
drivers/input/misc/wistron_btns.c

index 5c4956678cd0aeed39a5bb756940939850ac271d..907b1a4e6633ad358cefdeb9f8876d52b7c60bb6 100644 (file)
@@ -990,8 +990,8 @@ static int __init copy_keymap(void)
        for (key = keymap; key->type != KE_END; key++)
                length++;
 
-       new_keymap = kmemdup(keymap, length * sizeof(struct key_entry),
-                            GFP_KERNEL);
+       new_keymap = kmemdup_array(keymap, length, sizeof(struct key_entry),
+                                  GFP_KERNEL);
        if (!new_keymap)
                return -ENOMEM;