rtlwifi: fix potential NULL pointer dereference
authorPing-Ke Shih <pkshih@realtek.com>
Tue, 12 Mar 2019 09:06:48 +0000 (17:06 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 31 May 2019 13:46:26 +0000 (06:46 -0700)
[ Upstream commit 60209d482b97743915883d293c8b85226d230c19 ]

In case dev_alloc_skb fails, the fix safely returns to avoid
potential NULL pointer dereference.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wireless/realtek/rtlwifi/rtl8188ee/fw.c
drivers/net/wireless/realtek/rtlwifi/rtl8192c/fw_common.c
drivers/net/wireless/realtek/rtlwifi/rtl8192ee/fw.c
drivers/net/wireless/realtek/rtlwifi/rtl8723ae/fw.c
drivers/net/wireless/realtek/rtlwifi/rtl8723be/fw.c
drivers/net/wireless/realtek/rtlwifi/rtl8821ae/fw.c

index 6387451..b5f91c9 100644 (file)
@@ -622,6 +622,8 @@ void rtl88e_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished)
                      u1rsvdpageloc, 3);
 
        skb = dev_alloc_skb(totalpacketlen);
+       if (!skb)
+               return;
        skb_put_data(skb, &reserved_page_packet, totalpacketlen);
 
        rtstatus = rtl_cmd_send_packet(hw, skb);
index f3bff66..81ec0e6 100644 (file)
@@ -646,6 +646,8 @@ void rtl92c_set_fw_rsvdpagepkt(struct ieee80211_hw *hw,
 
 
        skb = dev_alloc_skb(totalpacketlen);
+       if (!skb)
+               return;
        skb_put_data(skb, &reserved_page_packet, totalpacketlen);
 
        if (cmd_send_packet)
index 84a0d0e..a933490 100644 (file)
@@ -766,6 +766,8 @@ void rtl92ee_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished)
                      u1rsvdpageloc, 3);
 
        skb = dev_alloc_skb(totalpacketlen);
+       if (!skb)
+               return;
        skb_put_data(skb, &reserved_page_packet, totalpacketlen);
 
        rtstatus = rtl_cmd_send_packet(hw, skb);
index bf9859f..52f1087 100644 (file)
@@ -470,6 +470,8 @@ void rtl8723e_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished)
                      u1rsvdpageloc, 3);
 
        skb = dev_alloc_skb(totalpacketlen);
+       if (!skb)
+               return;
        skb_put_data(skb, &reserved_page_packet, totalpacketlen);
 
        rtstatus = rtl_cmd_send_packet(hw, skb);
index f2441fb..307c2bd 100644 (file)
@@ -584,6 +584,8 @@ void rtl8723be_set_fw_rsvdpagepkt(struct ieee80211_hw *hw,
                      u1rsvdpageloc, sizeof(u1rsvdpageloc));
 
        skb = dev_alloc_skb(totalpacketlen);
+       if (!skb)
+               return;
        skb_put_data(skb, &reserved_page_packet, totalpacketlen);
 
        rtstatus = rtl_cmd_send_packet(hw, skb);
index d868a03..d7235f6 100644 (file)
@@ -1645,6 +1645,8 @@ out:
                      &reserved_page_packet_8812[0], totalpacketlen);
 
        skb = dev_alloc_skb(totalpacketlen);
+       if (!skb)
+               return;
        skb_put_data(skb, &reserved_page_packet_8812, totalpacketlen);
 
        rtstatus = rtl_cmd_send_packet(hw, skb);
@@ -1781,6 +1783,8 @@ out:
                      &reserved_page_packet_8821[0], totalpacketlen);
 
        skb = dev_alloc_skb(totalpacketlen);
+       if (!skb)
+               return;
        skb_put_data(skb, &reserved_page_packet_8821, totalpacketlen);
 
        rtstatus = rtl_cmd_send_packet(hw, skb);