Message ID | 20230822111832.822367-3-ruanjinjie@huawei.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | media: cx231xx: Add two macros and switch to use kmemdup() helper | expand |
diff --git a/drivers/media/usb/cx231xx/cx231xx-core.c b/drivers/media/usb/cx231xx/cx231xx-core.c index ce9e72b9b052..1910adc2aeb2 100644 --- a/drivers/media/usb/cx231xx/cx231xx-core.c +++ b/drivers/media/usb/cx231xx/cx231xx-core.c @@ -751,10 +751,9 @@ int cx231xx_ep5_bulkout(struct cx231xx *dev, u8 *firmware, u16 size) int ret = -ENOMEM; u32 *buffer; - buffer = kzalloc(BUF_SIZE, GFP_KERNEL); + buffer = kmemdup(firmware, BUF_SIZE, GFP_KERNEL); if (buffer == NULL) return -ENOMEM; - memcpy(&buffer[0], firmware, BUF_SIZE); ret = usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, 5), buffer, BUF_SIZE, &actlen, TIMEOUT_MS);
Use kmemdup() helper instead of open-coding to simplify the code. Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> --- v2: - Replace the magic constant "4096" with BUF_SIZE macro in another patch. --- drivers/media/usb/cx231xx/cx231xx-core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)