Commit 25b95133 authored by Ajay Singh's avatar Ajay Singh Committed by Greg Kroah-Hartman

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: default avatarAjay Singh <ajay.kathat@microchip.com>
Reviewed-by: default avatarClaudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 56294f87
...@@ -3465,12 +3465,15 @@ void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length) ...@@ -3465,12 +3465,15 @@ void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length)
msg.vif = vif; msg.vif = vif;
msg.body.net_info.len = length; msg.body.net_info.len = length;
msg.body.net_info.buffer = kmalloc(length, GFP_KERNEL); msg.body.net_info.buffer = kmemdup(buffer, length, GFP_KERNEL);
memcpy(msg.body.net_info.buffer, buffer, length); if (!msg.body.net_info.buffer)
return;
result = wilc_enqueue_cmd(&msg); result = wilc_enqueue_cmd(&msg);
if (result) if (result) {
netdev_err(vif->ndev, "message parameters (%d)\n", 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) void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment