[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250114011255.871225-1-zhangheng@kylinos.cn>
Date: Tue, 14 Jan 2025 09:12:55 +0800
From: Zhang Heng <zhangheng@...inos.cn>
To: mkrufky@...uxtv.org,
mchehab@...nel.org
Cc: linux-media@...r.kernel.org,
linux-kernel@...r.kernel.org,
Zhang Heng <zhangheng@...inos.cn>
Subject: [PATCH] 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@...inos.cn>
---
drivers/media/usb/dvb-usb/cxusb-analog.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/media/usb/dvb-usb/cxusb-analog.c b/drivers/media/usb/dvb-usb/cxusb-analog.c
index 8253046cd6e6..3bbee1fcbc8d 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;
--
2.45.2
Powered by blists - more mailing lists