[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20240826034638.2837-1-shenlichuan@vivo.com>
Date: Mon, 26 Aug 2024 11:46:38 +0800
From: Shen Lichuan <shenlichuan@...o.com>
To: isely@...ox.com,
mchehab@...nel.org
Cc: linux-media@...r.kernel.org,
linux-kernel@...r.kernel.org,
opensource.kernel@...o.com,
Shen Lichuan <shenlichuan@...o.com>
Subject: [PATCH v1] media: pvrusb2: Use kmemdup_array instead of kmemdup for multiple allocation
Let the kmemdup_array() take care about multiplication
and possible overflows.
Using kmemdup_array() is more appropriate and makes the code
easier to audit.
Signed-off-by: Shen Lichuan <shenlichuan@...o.com>
---
drivers/media/usb/pvrusb2/pvrusb2-io.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-io.c b/drivers/media/usb/pvrusb2/pvrusb2-io.c
index 675dc7153e2b..28ffe7981f8c 100644
--- a/drivers/media/usb/pvrusb2/pvrusb2-io.c
+++ b/drivers/media/usb/pvrusb2/pvrusb2-io.c
@@ -335,8 +335,8 @@ static int pvr2_stream_buffer_count(struct pvr2_stream *sp, unsigned int cnt)
if (scnt < sp->buffer_slot_count) {
struct pvr2_buffer **nb = NULL;
if (scnt) {
- nb = kmemdup(sp->buffers, scnt * sizeof(*nb),
- GFP_KERNEL);
+ nb = kmemdup_array(sp->buffers, scnt, sizeof(*nb),
+ GFP_KERNEL);
if (!nb) return -ENOMEM;
}
kfree(sp->buffers);
--
2.17.1
Powered by blists - more mailing lists