staging: r8188eu: use kmemdup instead of kzalloc and memcpy
authorMichael Straube <straube.linux@gmail.com>
Fri, 7 Jan 2022 10:36:10 +0000 (11:36 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 25 Jan 2022 15:13:43 +0000 (16:13 +0100)
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>
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
drivers/staging/r8188eu/include/rtl8188e_hal.h

index ee684b3..f7ae2fc 100644 (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);
 
index 3da0475..051f3b9 100644 (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 */