summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKangjie Lu <kjlu@umn.edu>2018-12-22 16:58:06 -0600
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-01-15 16:08:28 +0100
commit0a54ea9f481f1a2ca5a171e91ddaacb75040f287 (patch)
treea6d08dbb59397a94b470c57d6e863ff03c30f72b
parente4abc2488073a1e2764313feac5312622c7f04f9 (diff)
staging: rtlwifi: rtl8822b: fix a missing check of alloc_skb
__netdev_alloc_skb() return NULl when it fails. skb_put() further uses it even when the allocation fails, leading to NULL pointer dereference. The fix inserts a check for the return value of __netdev_alloc_skb(). Signed-off-by: Kangjie Lu <kjlu@umn.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/rtlwifi/rtl8822be/fw.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/staging/rtlwifi/rtl8822be/fw.c b/drivers/staging/rtlwifi/rtl8822be/fw.c
index a40396614814..f061dd1382aa 100644
--- a/drivers/staging/rtlwifi/rtl8822be/fw.c
+++ b/drivers/staging/rtlwifi/rtl8822be/fw.c
@@ -486,6 +486,8 @@ bool rtl8822b_halmac_cb_write_data_h2c(struct rtl_priv *rtlpriv, u8 *buf,
/* without GFP_DMA, pci_map_single() may not work */
skb = __netdev_alloc_skb(NULL, size, GFP_ATOMIC | GFP_DMA);
+ if (!skb)
+ return false;
memcpy((u8 *)skb_put(skb, size), buf, size);
return _rtl8822be_send_bcn_or_cmd_packet(rtlpriv->hw, skb, H2C_QUEUE);