浏览代码

staging: wilc1000: use kmemdup in host_int_add_station

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>
Chaehyun Lim 9 年之前
父节点
当前提交
7897bd00f6
共有 1 个文件被更改,包括 3 次插入5 次删除
  1. 3 5
      drivers/staging/wilc1000/host_interface.c

+ 3 - 5
drivers/staging/wilc1000/host_interface.c

@@ -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));
 	memcpy(add_sta_info, sta_param, sizeof(struct add_sta_param));
 	if (add_sta_info->rates_len > 0) {
 	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)
 		if (!rates)
 			return -ENOMEM;
 			return -ENOMEM;
-
-		memcpy(rates, sta_param->rates,
-		       add_sta_info->rates_len);
 		add_sta_info->rates = rates;
 		add_sta_info->rates = rates;
 	}
 	}