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

media: usb: use kmalloc_array() to replace kmalloc()

Use kmalloc_array() to replace kmalloc() with multiplication.
kmalloc_array() has multiply overflow check, which will be safer.

Signed-off-by: Zhang Heng <zhangheng@kylinos.cn>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>

authored by

Zhang Heng and committed by
Hans Verkuil
8deb1e2a 648dec68

+2 -2
+2 -2
drivers/media/usb/dvb-usb/cxusb-analog.c
··· 817 817 * doing a large continuous allocation when (if) 818 818 * s-g isochronous USB transfers are supported 819 819 */ 820 - streambuf = kmalloc(npackets * CXUSB_VIDEO_PKT_SIZE, 821 - GFP_KERNEL); 820 + streambuf = kmalloc_array(npackets, CXUSB_VIDEO_PKT_SIZE, 821 + GFP_KERNEL); 822 822 if (!streambuf) { 823 823 if (i < 2) { 824 824 ret = -ENOMEM;