staging: wilc1000: add check for kmalloc allocation failure.

Add a sanity check that wid.val has been allocated, fixes a null
pointer deference on stamac when calling ether_add_copy.

Detected by CoverityScan, CID#1369537 ("Dereference null return value")

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Colin Ian King 2017-02-28 11:47:33 +00:00 коммит произвёл Greg Kroah-Hartman
Родитель 2af5f669be
Коммит 6cc0c259d0
1 изменённых файлов: 2 добавлений и 0 удалений

Просмотреть файл

@ -1928,6 +1928,8 @@ static s32 Handle_Get_InActiveTime(struct wilc_vif *vif,
wid.type = WID_STR; wid.type = WID_STR;
wid.size = ETH_ALEN; wid.size = ETH_ALEN;
wid.val = kmalloc(wid.size, GFP_KERNEL); wid.val = kmalloc(wid.size, GFP_KERNEL);
if (!wid.val)
return -ENOMEM;
stamac = wid.val; stamac = wid.val;
ether_addr_copy(stamac, strHostIfStaInactiveT->mac); ether_addr_copy(stamac, strHostIfStaInactiveT->mac);