staging: r8188eu: use kmemdup instead of kzalloc and memcpy

Use kmemdup instead of kzalloc and memcpy in load_firmware().

Signed-off-by: Michael Straube <straube.linux@gmail.com>
Link: https://lore.kernel.org/r/20220107103620.15648-10-straube.linux@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Michael Straube
2022-01-07 11:36:10 +01:00
committed by Greg Kroah-Hartman
parent 2f8e84b2d1
commit 2441fa93a8
2 changed files with 1 additions and 7 deletions

View File

@@ -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);

View File

@@ -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 */