From: Zhang Heng Date: Tue, 14 Jan 2025 01:12:55 +0000 (+0800) Subject: media: usb: use kmalloc_array() to replace kmalloc() X-Git-Tag: v6.15-rc1~174^2~125 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8deb1e2a392bbebe159aa4f4d33f4e0a62260c24;p=thirdparty%2Fkernel%2Flinux.git 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 Signed-off-by: Hans Verkuil --- diff --git a/drivers/media/usb/dvb-usb/cxusb-analog.c b/drivers/media/usb/dvb-usb/cxusb-analog.c index 8253046cd6e60..3bbee1fcbc8dc 100644 --- a/drivers/media/usb/dvb-usb/cxusb-analog.c +++ b/drivers/media/usb/dvb-usb/cxusb-analog.c @@ -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;