From: Colin Ian King Date: Tue, 28 Feb 2017 11:47:33 +0000 (+0000) Subject: staging: wilc1000: add check for kmalloc allocation failure. X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=6cc0c259d034c6ab48f4e12f505213988e73d380;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git 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 Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index c2a3424c35cb..f848bb85ff1f 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -1928,6 +1928,8 @@ static s32 Handle_Get_InActiveTime(struct wilc_vif *vif, wid.type = WID_STR; wid.size = ETH_ALEN; wid.val = kmalloc(wid.size, GFP_KERNEL); + if (!wid.val) + return -ENOMEM; stamac = wid.val; ether_addr_copy(stamac, strHostIfStaInactiveT->mac);