staging: rtlwifi: rtl8822b: fix to avoid potential NULL pointer dereference
authorAditya Pakki <pakki001@umn.edu>
Wed, 20 Mar 2019 17:02:49 +0000 (12:02 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 21 Mar 2019 07:32:57 +0000 (08:32 +0100)
skb allocated via dev_alloc_skb can fail and return a NULL pointer.
This patch avoids such a scenario and returns, consistent with other
invocations.

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtlwifi/rtl8822be/fw.c

index f061dd1382aa102e53ac532844c8e2c9959ae568..cf6b7a80b753b35dc2d488e589f97f9d1899fedb 100644 (file)
@@ -743,6 +743,8 @@ void rtl8822be_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished)
                      u1_rsvd_page_loc, 3);
 
        skb = dev_alloc_skb(totalpacketlen);
+       if (!skb)
+               return;
        memcpy((u8 *)skb_put(skb, totalpacketlen), &reserved_page_packet,
               totalpacketlen);