summaryrefslogtreecommitdiffstats
path: root/drivers/staging/wilc1000/host_interface.c
diff options
context:
space:
mode:
authorChaehyun Lim <chaehyun.lim@gmail.com>2016-01-05 23:06:55 +0900
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-02-03 15:16:26 -0800
commit1a271d996097367da1f35cf257da11f472fd39d2 (patch)
tree9c8ae241c4df8aa23a275956a4ecc1e8b0a5435c /drivers/staging/wilc1000/host_interface.c
parentd317818bf4c1238c21efbe407e24727b50f324a1 (diff)
downloadop-kernel-dev-1a271d996097367da1f35cf257da11f472fd39d2.zip
op-kernel-dev-1a271d996097367da1f35cf257da11f472fd39d2.tar.gz
staging: wilc1000: use kmemdup instead of kmalloc/memcpy
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/wilc1000/host_interface.c')
-rw-r--r--drivers/staging/wilc1000/host_interface.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
index 07fe5c8..3de0fad 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -3704,12 +3704,16 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type,
msg.body.scan_info.arg = user_arg;
msg.body.scan_info.ch_list_len = ch_list_len;
- msg.body.scan_info.ch_freq_list = kmalloc(ch_list_len, GFP_KERNEL);
- memcpy(msg.body.scan_info.ch_freq_list, ch_freq_list, ch_list_len);
+ msg.body.scan_info.ch_freq_list = kmemdup(ch_freq_list,
+ ch_list_len,
+ GFP_KERNEL);
+ if (!msg.body.scan_info.ch_freq_list)
+ return -ENOMEM;
msg.body.scan_info.ies_len = ies_len;
- msg.body.scan_info.ies = kmalloc(ies_len, GFP_KERNEL);
- memcpy(msg.body.scan_info.ies, ies, ies_len);
+ msg.body.scan_info.ies = kmemdup(ies, ies_len, GFP_KERNEL);
+ if (!msg.body.scan_info.ies)
+ return -ENOMEM;
result = wilc_mq_send(&hif_msg_q, &msg, sizeof(struct host_if_msg));
if (result) {
OpenPOWER on IntegriCloud