staging: rtl8723bs: use kmemdup for allocation and copy
authorDafna Hirschfeld <dafna3@gmail.com>
Tue, 27 Feb 2018 21:44:27 +0000 (23:44 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 1 Mar 2018 16:21:49 +0000 (17:21 +0100)
Use kmemdup instead of kzalloc and memcpy to simplify the code.
Issue found with coccicheck.

Signed-off-by: Dafna Hirschfeld <dafna3@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c

index d6cef9e8378d36e4a013f1535bb0d694e828e4da..0ce9b47d644dd96c3b0c0c7f677a4d8bfc2e5b11 100644 (file)
@@ -433,13 +433,12 @@ s32 rtl8723b_FirmwareDownload(struct adapter *padapter, bool  bUsedWoWLANFw)
                goto exit;
        }
 
-       pFirmware->szFwBuffer = kzalloc(fw->size, GFP_KERNEL);
+       pFirmware->szFwBuffer = kmemdup(fw->data, fw->size, GFP_KERNEL);
        if (!pFirmware->szFwBuffer) {
                rtStatus = _FAIL;
                goto exit;
        }
 
-       memcpy(pFirmware->szFwBuffer, fw->data, fw->size);
        pFirmware->ulFwLength = fw->size;
        release_firmware(fw);
        if (pFirmware->ulFwLength > FW_8723B_SIZE) {