diff options
author | Ajay Singh <ajay.kathat@microchip.com> | 2018-03-26 17:15:56 +0530 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-03-28 13:37:09 +0200 |
commit | 25b951332da01e4e4d5e9d8d36518b46e1e4015c (patch) | |
tree | 70f1ea57c7d413dcf3bf7911aa1e3c3c29a10d9c /drivers/staging/wilc1000 | |
parent | 56294f87149fc83a7eb642d6b2ea55a82ba8cd78 (diff) |
staging: wilc1000: avoid 'NULL' pointer access in wilc_network_info_received()
Added 'NULL' check before accessing the allocated memory. Free up the
memory incase of failure to enqueue the command. Used kmemdup instead of
kmalloc & memcpy.
Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/wilc1000')
-rw-r--r-- | drivers/staging/wilc1000/host_interface.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 3256a1da7e46..020baf15e02d 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -3465,12 +3465,15 @@ void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length) msg.vif = vif; msg.body.net_info.len = length; - msg.body.net_info.buffer = kmalloc(length, GFP_KERNEL); - memcpy(msg.body.net_info.buffer, buffer, length); + msg.body.net_info.buffer = kmemdup(buffer, length, GFP_KERNEL); + if (!msg.body.net_info.buffer) + return; result = wilc_enqueue_cmd(&msg); - if (result) + if (result) { netdev_err(vif->ndev, "message parameters (%d)\n", result); + kfree(msg.body.net_info.buffer); + } } void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length) |