* [PATCH] rtlwifi: rtl8822b: fix a missing check of alloc_skb
@ 2018-12-22 22:58 Kangjie Lu
0 siblings, 0 replies; only message in thread
From: Kangjie Lu @ 2018-12-22 22:58 UTC (permalink / raw)
To: kjlu
Cc: pakki001, Greg Kroah-Hartman, Sabin Mihai Rapan,
Nathan Chancellor, devel, linux-kernel
__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>
---
drivers/staging/rtlwifi/rtl8822be/fw.c | 2 ++
1 file changed, 2 insertions(+)
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);
--
2.17.2 (Apple Git-113)
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2018-12-22 22:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-22 22:58 [PATCH] rtlwifi: rtl8822b: fix a missing check of alloc_skb Kangjie Lu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.