diff options
author | Shen Lichuan <shenlichuan@vivo.com> | 2024-08-26 11:46:38 +0800 |
---|---|---|
committer | Hans Verkuil <hverkuil-cisco@xs4all.nl> | 2024-10-12 16:28:24 +0200 |
commit | 4510319676bdf96da819599643809e5155ef3460 (patch) | |
tree | 52082da6dd75e2963b6ccbdb7acd3b071545474d | |
parent | 953c03d8cb41d08fe6994f5d94c4393ac9da2f13 (diff) |
media: pvrusb2: 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>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
-rw-r--r-- | drivers/media/usb/pvrusb2/pvrusb2-io.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-io.c b/drivers/media/usb/pvrusb2/pvrusb2-io.c index 675dc7153e2b..28ffe7981f8c 100644 --- a/drivers/media/usb/pvrusb2/pvrusb2-io.c +++ b/drivers/media/usb/pvrusb2/pvrusb2-io.c @@ -335,8 +335,8 @@ static int pvr2_stream_buffer_count(struct pvr2_stream *sp, unsigned int cnt) if (scnt < sp->buffer_slot_count) { struct pvr2_buffer **nb = NULL; if (scnt) { - nb = kmemdup(sp->buffers, scnt * sizeof(*nb), - GFP_KERNEL); + nb = kmemdup_array(sp->buffers, scnt, sizeof(*nb), + GFP_KERNEL); if (!nb) return -ENOMEM; } kfree(sp->buffers); |