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>
This commit is contained in:
Chaehyun Lim 2015-10-27 20:40:37 +09:00 committed by Greg Kroah-Hartman
parent 0b2cc3e57c
commit 1cc0c328d5

View file

@ -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.type = WEP;
msg.body.key_info.action = ADDKEY; msg.body.key_info.action = ADDKEY;
msg.drv = hif_drv; msg.drv = hif_drv;
msg.body.key_info.attr.wep.key = kmalloc(len, GFP_KERNEL); msg.body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL);
memcpy(msg.body.key_info.attr.wep.key, key, len); 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.key_len = len;
msg.body.key_info.attr.wep.index = index; msg.body.key_info.attr.wep.index = index;