Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Shen Lichuan and committed by
Hans Verkuil
45103196 953c03d8

+2 -2
+2 -2
drivers/media/usb/pvrusb2/pvrusb2-io.c
··· 335 335 if (scnt < sp->buffer_slot_count) { 336 336 struct pvr2_buffer **nb = NULL; 337 337 if (scnt) { 338 - nb = kmemdup(sp->buffers, scnt * sizeof(*nb), 339 - GFP_KERNEL); 338 + nb = kmemdup_array(sp->buffers, scnt, sizeof(*nb), 339 + GFP_KERNEL); 340 340 if (!nb) return -ENOMEM; 341 341 } 342 342 kfree(sp->buffers);