diff options
author | Chaehyun Lim | 2015-11-08 08:49:16 +0100 |
---|---|---|
committer | Greg Kroah-Hartman | 2015-12-18 23:14:03 +0100 |
commit | 9bfda3820fe4e7e509aebe3b32b1514b5a615851 (patch) | |
tree | 1d3f144e82e839edb78bc63fdb4be47d4bc3d654 /drivers/staging/wilc1000/host_interface.c | |
parent | staging: wilc1000: rename u8KeyLen in host_int_add_rx_gtk (diff) | |
download | kernel-qcow2-linux-9bfda3820fe4e7e509aebe3b32b1514b5a615851.tar.gz kernel-qcow2-linux-9bfda3820fe4e7e509aebe3b32b1514b5a615851.tar.xz kernel-qcow2-linux-9bfda3820fe4e7e509aebe3b32b1514b5a615851.zip |
staging: wilc1000: use kmemdup in host_int_add_rx_gtk
This patch changes kmalloc followed by memcpy to kmemdup.
The error checking is also added 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.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 0028bed54eae..51b6ddb821f7 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -3296,8 +3296,11 @@ int host_int_add_rx_gtk(struct host_if_drv *hif_drv, const u8 *rx_gtk, key_len += TX_MIC_KEY_LEN; if (key_rsc) { - msg.body.key_info.attr.wpa.seq = kmalloc(key_rsc_len, GFP_KERNEL); - memcpy(msg.body.key_info.attr.wpa.seq, key_rsc, key_rsc_len); + msg.body.key_info.attr.wpa.seq = kmemdup(key_rsc, + key_rsc_len, + GFP_KERNEL); + if (!msg.body.key_info.attr.wpa.seq) + return -ENOMEM; } msg.id = HOST_IF_MSG_KEY; @@ -3311,8 +3314,11 @@ int host_int_add_rx_gtk(struct host_if_drv *hif_drv, const u8 *rx_gtk, if (mode == STATION_MODE) msg.body.key_info.action = ADDKEY; - msg.body.key_info.attr.wpa.key = kmalloc(key_len, GFP_KERNEL); - memcpy(msg.body.key_info.attr.wpa.key, rx_gtk, gtk_key_len); + msg.body.key_info.attr.wpa.key = kmemdup(rx_gtk, + key_len, + GFP_KERNEL); + if (!msg.body.key_info.attr.wpa.key) + return -ENOMEM; if (rx_mic) memcpy(msg.body.key_info.attr.wpa.key + 16, rx_mic, |