]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: usb: use kmalloc_array() to replace kmalloc()
authorZhang Heng <zhangheng@kylinos.cn>
Tue, 14 Jan 2025 01:12:55 +0000 (09:12 +0800)
committerHans Verkuil <hverkuil@xs4all.nl>
Fri, 21 Feb 2025 09:33:04 +0000 (10:33 +0100)
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>
drivers/media/usb/dvb-usb/cxusb-analog.c

index 8253046cd6e60195264387000789d4739fdffe51..3bbee1fcbc8dc3d7ef7b408333d4af1f16bb1d6d 100644 (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;