Use kmemdup instead of kzalloc and memcpy in load_firmware(). Signed-off-by: Michael Straube <straube.linux@xxxxxxxxx> --- drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 7 +------ drivers/staging/r8188eu/include/rtl8188e_hal.h | 1 - 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c index ee684b37ff91..f7ae2fc0d2b9 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c @@ -525,18 +525,13 @@ static int load_firmware(struct rt_firmware *rtfw, struct device *device) ret = _FAIL; goto exit; } - if (fw->size > FW_8188E_SIZE) { - ret = _FAIL; - goto exit; - } - rtfw->data = kzalloc(FW_8188E_SIZE, GFP_KERNEL); + rtfw->data = kmemdup(fw->data, fw->size, GFP_KERNEL); if (!rtfw->data) { pr_err("Failed to allocate rtfw->data\n"); ret = _FAIL; goto exit; } - memcpy(rtfw->data, fw->data, fw->size); rtfw->size = fw->size; dev_dbg(device, "!bUsedWoWLANFw, FmrmwareLen:%d+\n", rtfw->size); diff --git a/drivers/staging/r8188eu/include/rtl8188e_hal.h b/drivers/staging/r8188eu/include/rtl8188e_hal.h index 3da04751f25d..051f3b9fe726 100644 --- a/drivers/staging/r8188eu/include/rtl8188e_hal.h +++ b/drivers/staging/r8188eu/include/rtl8188e_hal.h @@ -35,7 +35,6 @@ #define PageNum_128(_Len) (u32)(((_Len)>>7) + ((_Len) & 0x7F ? 1 : 0)) /* download firmware related data structure */ -#define FW_8188E_SIZE 0x4000 /* 16384,16k */ #define FW_8188E_START_ADDRESS 0x1000 #define MAX_PAGE_SIZE 4096 /* @ page : 4k bytes */ -- 2.34.1