* [PATCH v1] Input: wistron_btns - use kmemdup_array instead of kmemdup for multiple allocation
@ 2024-08-26 4:52 Shen Lichuan
2024-08-26 17:25 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: Shen Lichuan @ 2024-08-26 4:52 UTC (permalink / raw)
To: mitr, dmitry.torokhov; +Cc: linux-input, linux-kernel, Shen Lichuan
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>
---
drivers/input/misc/wistron_btns.c | 4 ++--
1 file 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;
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v1] Input: wistron_btns - use kmemdup_array instead of kmemdup for multiple allocation
2024-08-26 4:52 [PATCH v1] Input: wistron_btns - use kmemdup_array instead of kmemdup for multiple allocation Shen Lichuan
@ 2024-08-26 17:25 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2024-08-26 17:25 UTC (permalink / raw)
To: Shen Lichuan; +Cc: mitr, linux-input, linux-kernel
On Mon, Aug 26, 2024 at 12:52:53PM +0800, Shen Lichuan wrote:
> 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>
Applied, thank you.
--
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-08-26 17:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-26 4:52 [PATCH v1] Input: wistron_btns - use kmemdup_array instead of kmemdup for multiple allocation Shen Lichuan
2024-08-26 17:25 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).