staging: ks7010: replace kmalloc() + memcpy() with kmemdup()
authorJi-Hun Kim <ji_hun.kim@samsung.com>
Fri, 6 Apr 2018 04:57:20 +0000 (13:57 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 23 Apr 2018 12:24:47 +0000 (14:24 +0200)
Use kmemdup rather than duplicating its implementation.

Signed-off-by: Ji-Hun Kim <ji_hun.kim@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/ks7010/ks7010_sdio.c

index a79438b..9978915 100644 (file)
@@ -589,11 +589,10 @@ static int ks7010_sdio_update_index(struct ks_wlan_private *priv, u32 index)
        int ret;
        unsigned char *data_buf;
 
-       data_buf = kmalloc(sizeof(u32), GFP_KERNEL);
+       data_buf = kmemdup(&index, sizeof(u32), GFP_KERNEL);
        if (!data_buf)
                return -ENOMEM;
 
-       memcpy(data_buf, &index, sizeof(index));
        ret = ks7010_sdio_write(priv, WRITE_INDEX, data_buf, sizeof(index));
        if (ret)
                goto err_free_data_buf;