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>
This commit is contained in:
Zhang Heng 2025-01-14 09:12:55 +08:00 committed by Hans Verkuil
parent 648dec6840
commit 8deb1e2a39

View File

@ -817,8 +817,8 @@ static int cxusb_medion_v_start_streaming(struct vb2_queue *q,
* doing a large continuous allocation when (if)
* s-g isochronous USB transfers are supported
*/
streambuf = kmalloc(npackets * CXUSB_VIDEO_PKT_SIZE,
GFP_KERNEL);
streambuf = kmalloc_array(npackets, CXUSB_VIDEO_PKT_SIZE,
GFP_KERNEL);
if (!streambuf) {
if (i < 2) {
ret = -ENOMEM;