summaryrefslogtreecommitdiff
path: root/drivers/staging/wilc1000
diff options
context:
space:
mode:
authorChaehyun Lim <chaehyun.lim@gmail.com>2015-10-27 14:40:37 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-10-29 02:49:50 +0300
commit1cc0c328d564b0061a0bd156e8734125a64a0531 (patch)
treeecc496f4445890dbe3595ce4fec890a99c0422da /drivers/staging/wilc1000
parent0b2cc3e57c7d1de64beaba467058e85489ad4ab1 (diff)
downloadlinux-1cc0c328d564b0061a0bd156e8734125a64a0531.tar.xz
staging: wilc1000: replace kmalloc/memcpy with kmemdup
This patch replaces kmalloc followed by memcpy with kmemdup. It is also added error checking of kmemdup. Signed-off-by: Chaehyun Lim <chaehyun.lim@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/wilc1000')
-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 af98c43fef0e..28fef2525086 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -3124,8 +3124,10 @@ int host_int_add_wep_key_bss_sta(struct host_if_drv *hif_drv,
msg.body.key_info.type = WEP;
msg.body.key_info.action = ADDKEY;
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;