staging: wilc1000: use kmemdup in host_int_add_station
authorChaehyun Lim <chaehyun.lim@gmail.com>
Fri, 6 Nov 2015 10:11:20 +0000 (19:11 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 16 Nov 2015 04:02:47 +0000 (20:02 -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 b870809037b11ff5a0d3ba71dfeae59eb7019cbc..db7060f2ba12dc51e736b8282fb1ca2e555f691b 100644 (file)
@@ -4560,13 +4560,11 @@ int host_int_add_station(struct host_if_drv *hif_drv,
 
        memcpy(add_sta_info, sta_param, sizeof(struct add_sta_param));
        if (add_sta_info->rates_len > 0) {
-               u8 *rates = kmalloc(add_sta_info->rates_len, GFP_KERNEL);
-
+               u8 *rates = kmemdup(sta_param->rates,
+                                   add_sta_info->rates_len,
+                                   GFP_KERNEL);
                if (!rates)
                        return -ENOMEM;
-
-               memcpy(rates, sta_param->rates,
-                      add_sta_info->rates_len);
                add_sta_info->rates = rates;
        }