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 <bianpan2016@163.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Pan Bian 2017-04-23 19:53:58 +08:00 committed by Greg Kroah-Hartman
parent 3c2bf0bd08
commit 9e96652756
1 changed files with 2 additions and 0 deletions

View File

@ -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);