]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
staging: wilc1000: add check for kmalloc allocation failure.
authorColin Ian King <colin.king@canonical.com>
Tue, 28 Feb 2017 11:47:33 +0000 (11:47 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 22 Mar 2018 08:23:19 +0000 (09:23 +0100)
[ Upstream commit 6cc0c259d034c6ab48f4e12f505213988e73d380 ]

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>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wilc1000/host_interface.c

index dbbe72c7e25572918d4aea2e8c44c00026c790a3..f78353ddeea5c54fb8264fed4b15d0c6feca5b83 100644 (file)
@@ -2179,6 +2179,8 @@ static s32 Handle_Get_InActiveTime(struct host_if_drv *hif_drv,
        wid.type = WID_STR;
        wid.size = ETH_ALEN;
        wid.val = kmalloc(wid.size, GFP_KERNEL);
+       if (!wid.val)
+               return -ENOMEM;
 
        stamac = wid.val;
        memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);