From 747a64bd01f869f8b987e17992bba1db8108161a Mon Sep 17 00:00:00 2001 From: Malcolm Priestley Date: Sun, 19 Jan 2020 12:04:34 +0000 Subject: [PATCH] staging: vt6656: Remove memory buffer from vnt_download_firmware. The memory buffer is being done twice here as vnt_control_out passes it straight to kmemdup. Remove buffer and add const to the variable in vnt_control_out to pass the pointer to it. Signed-off-by: Malcolm Priestley Link: https://lore.kernel.org/r/be025ed0-204d-e957-4bc9-963e841fcb2c@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/firmware.c | 14 ++------------ drivers/staging/vt6656/usbpipe.c | 2 +- drivers/staging/vt6656/usbpipe.h | 2 +- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/drivers/staging/vt6656/firmware.c b/drivers/staging/vt6656/firmware.c index 60a00af..70358d4 100644 --- a/drivers/staging/vt6656/firmware.c +++ b/drivers/staging/vt6656/firmware.c @@ -30,7 +30,6 @@ int vnt_download_firmware(struct vnt_private *priv) { struct device *dev = &priv->usb->dev; const struct firmware *fw; - void *buffer = NULL; u16 length; int ii; int ret = 0; @@ -44,26 +43,17 @@ int vnt_download_firmware(struct vnt_private *priv) goto end; } - buffer = kmalloc(FIRMWARE_CHUNK_SIZE, GFP_KERNEL); - if (!buffer) { - ret = -ENOMEM; - goto free_fw; - } - for (ii = 0; ii < fw->size; ii += FIRMWARE_CHUNK_SIZE) { length = min_t(int, fw->size - ii, FIRMWARE_CHUNK_SIZE); - memcpy(buffer, fw->data + ii, length); ret = vnt_control_out(priv, 0, 0x1200 + ii, 0x0000, length, - buffer); + fw->data + ii); if (ret) - goto free_buffer; + goto free_fw; dev_dbg(dev, "Download firmware...%d %zu\n", ii, fw->size); } -free_buffer: - kfree(buffer); free_fw: release_firmware(fw); end: diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index d977d47..7bfccc4 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -34,7 +34,7 @@ #define USB_CTL_WAIT 500 /* ms */ int vnt_control_out(struct vnt_private *priv, u8 request, u16 value, - u16 index, u16 length, u8 *buffer) + u16 index, u16 length, const u8 *buffer) { int ret = 0; u8 *usb_buffer; diff --git a/drivers/staging/vt6656/usbpipe.h b/drivers/staging/vt6656/usbpipe.h index b65d9c0..4e3341b 100644 --- a/drivers/staging/vt6656/usbpipe.h +++ b/drivers/staging/vt6656/usbpipe.h @@ -21,7 +21,7 @@ #define VNT_REG_BLOCK_SIZE 64 int vnt_control_out(struct vnt_private *priv, u8 request, u16 value, - u16 index, u16 length, u8 *buffer); + u16 index, u16 length, const u8 *buffer); int vnt_control_in(struct vnt_private *priv, u8 request, u16 value, u16 index, u16 length, u8 *buffer); -- 2.7.4