diff options
author | Shen Lichuan <[email protected]> | 2024-08-26 12:52:53 +0800 |
---|---|---|
committer | Dmitry Torokhov <[email protected]> | 2024-08-26 10:22:00 -0700 |
commit | b7ffc98a6a55bf93021a5dcb88a7682ae6cb0177 (patch) | |
tree | 4a1d2053cea4b01986c4a64f537e9254938845d6 | |
parent | 6994d8b84bfd71431bfccb5baf84a827086d48a5 (diff) |
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 <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Dmitry Torokhov <[email protected]>
-rw-r--r-- | drivers/input/misc/wistron_btns.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c index 5c4956678cd0..907b1a4e6633 100644 --- a/drivers/input/misc/wistron_btns.c +++ b/drivers/input/misc/wistron_btns.c @@ -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; |