From: Pan Bian Date: Sun, 23 Apr 2017 11:53:58 +0000 (+0800) Subject: staging: wilc1000: fix unchecked return value X-Git-Tag: v4.14-rc1~980^2~53 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9e96652756ad647b7bcc03cb99ffc9756d7b5f93;p=platform%2Fkernel%2Flinux-rpi.git staging: wilc1000: fix unchecked return value Function dev_alloc_skb() will return a NULL pointer if there is no enough memory. However, in function WILC_WFI_mon_xmit(), its return value is used without validation. This may result in a bad memory access bug. This patch fixes the bug. Signed-off-by: Pan Bian Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/wilc1000/linux_mon.c b/drivers/staging/wilc1000/linux_mon.c index f328d75..c9782d4 100644 --- a/drivers/staging/wilc1000/linux_mon.c +++ b/drivers/staging/wilc1000/linux_mon.c @@ -197,6 +197,8 @@ static netdev_tx_t WILC_WFI_mon_xmit(struct sk_buff *skb, if (skb->data[0] == 0xc0 && (!(memcmp(broadcast, &skb->data[4], 6)))) { skb2 = dev_alloc_skb(skb->len + sizeof(struct wilc_wfi_radiotap_cb_hdr)); + if (!skb2) + return -ENOMEM; memcpy(skb_put(skb2, skb->len), skb->data, skb->len);