staging: wilc1000: handle_set_mac_address: use kmemdup
authorChaehyun Lim <chaehyun.lim@gmail.com>
Tue, 16 Feb 2016 08:39:51 +0000 (17:39 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 20 Feb 2016 00:55:33 +0000 (16:55 -0800)
This patch replaces kmalloc followed by memcpy with kmemdup.

Signed-off-by: Chaehyun Lim <chaehyun.lim@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wilc1000/host_interface.c

index 8bcf69a188324db3bf22025b601f735e05e00450..206ce70a6232249e4d6c9692289262ae5d0fca07 100644 (file)
@@ -429,13 +429,11 @@ static s32 handle_set_mac_address(struct wilc_vif *vif,
 {
        s32 result = 0;
        struct wid wid;
-       u8 *mac_buf = kmalloc(ETH_ALEN, GFP_KERNEL);
 
+       u8 *mac_buf = kmemdup(set_mac_addr->mac_addr, ETH_ALEN, GFP_KERNEL);
        if (!mac_buf)
                return -ENOMEM;
 
-       memcpy(mac_buf, set_mac_addr->mac_addr, ETH_ALEN);
-
        wid.id = (u16)WID_MAC_ADDR;
        wid.type = WID_STR;
        wid.val = mac_buf;