aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging
diff options
context:
space:
mode:
authorChaehyun Lim <chaehyun.lim@gmail.com>2015-10-28 08:19:27 +0900
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-10-29 08:50:45 +0900
commit58eabd68a438f8b4755fab7160a31745f5723db4 (patch)
treefd084d528f10c2829947da21645ee7efa728230f /drivers/staging
parentstaging: wilc1000: rename tenuAuth_type in host_int_add_wep_key_bss_ap (diff)
downloadlinux-dev-58eabd68a438f8b4755fab7160a31745f5723db4.tar.xz
linux-dev-58eabd68a438f8b4755fab7160a31745f5723db4.zip
staging: wilc1000: replace kmalloc/memcpy with kmemdup
This patch replaces kmalloc followed by memcpy with kmemdup. It is also added error checking to return -ENOMEM when kmemdup is failed. Signed-off-by: Chaehyun Lim <chaehyun.lim@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/wilc1000/host_interface.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
index 466fd5307978..9a6fcc7e844c 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -3165,8 +3165,10 @@ int host_int_add_wep_key_bss_ap(struct host_if_drv *hif_drv,
msg.body.key_info.type = WEP;
msg.body.key_info.action = ADDKEY_AP;
msg.drv = hif_drv;
- msg.body.key_info.attr.wep.key = kmalloc(len, GFP_KERNEL);
- memcpy(msg.body.key_info.attr.wep.key, key, len);
+ msg.body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL);
+ if (!msg.body.key_info.attr.wep.key)
+ return -ENOMEM;
+
msg.body.key_info.attr.wep.key_len = len;
msg.body.key_info.attr.wep.index = index;
msg.body.key_info.attr.wep.mode = mode;