mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-29 09:16:33 +00:00
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>
This commit is contained in:
parent
953c03d8cb
commit
4510319676
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user