staging: r8188eu: os_dep: use kmemdup instead of kzalloc and memcpy
authorSaurav Girepunje <saurav.girepunje@gmail.com>
Fri, 3 Sep 2021 17:56:17 +0000 (23:26 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 13 Sep 2021 06:49:46 +0000 (08:49 +0200)
Fixes coccicheck warning:WARNING opportunity for kmemdup in ioctl_linux.c

Acked-by: Phillip Potter <phil@philpotter.co.uk>
Signed-off-by: Saurav Girepunje <saurav.girepunje@gmail.com>
Link: https://lore.kernel.org/r/YTJhwQstKPUYRwN+@user
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/r8188eu/os_dep/ioctl_linux.c

index 61e4b2d..bd637a6 100644 (file)
@@ -585,14 +585,12 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie
        }
 
        if (ielen) {
-               buf = kzalloc(ielen, GFP_KERNEL);
+               buf = kmemdup(pie, ielen, GFP_KERNEL);
                if (!buf) {
                        ret =  -ENOMEM;
                        goto exit;
                }
 
-               memcpy(buf, pie, ielen);
-
                /* dump */
                {
                        int i;