Skip to content

Commit bdc4bf6

Browse files
jjuhllinvjw
authored andcommitted
rtlwifi: Fix possible NULL dereference
In drivers/net/wireless/rtlwifi/pci.c::_rtl_pci_rx_interrupt() we call dev_alloc_skb(), which may fail and return NULL, but we do not check the returned value against NULL before dereferencing the returned pointer. This may lead to a NULL pointer dereference which means we'll crash - not good. In a separate call to dev_alloc_skb(), the debug level is changed so that the failure message will always be logged. Signed-off-by: Jesper Juhl <jj@chaosbits.net> Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
1 parent 783cd01 commit bdc4bf6

File tree

1 file changed

+9
-2
lines changed
  • drivers/net/wireless/rtlwifi

1 file changed

+9
-2
lines changed

drivers/net/wireless/rtlwifi/pci.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,13 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
619619
struct sk_buff *uskb = NULL;
620620
u8 *pdata;
621621
uskb = dev_alloc_skb(skb->len + 128);
622+
if (!uskb) {
623+
RT_TRACE(rtlpriv,
624+
(COMP_INTR | COMP_RECV),
625+
DBG_EMERG,
626+
("can't alloc rx skb\n"));
627+
goto done;
628+
}
622629
memcpy(IEEE80211_SKB_RXCB(uskb),
623630
&rx_status,
624631
sizeof(rx_status));
@@ -641,7 +648,7 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
641648
new_skb = dev_alloc_skb(rtlpci->rxbuffersize);
642649
if (unlikely(!new_skb)) {
643650
RT_TRACE(rtlpriv, (COMP_INTR | COMP_RECV),
644-
DBG_DMESG,
651+
DBG_EMERG,
645652
("can't alloc skb for rx\n"));
646653
goto done;
647654
}
@@ -1066,9 +1073,9 @@ static int _rtl_pci_init_rx_ring(struct ieee80211_hw *hw)
10661073
struct sk_buff *skb =
10671074
dev_alloc_skb(rtlpci->rxbuffersize);
10681075
u32 bufferaddress;
1069-
entry = &rtlpci->rx_ring[rx_queue_idx].desc[i];
10701076
if (!skb)
10711077
return 0;
1078+
entry = &rtlpci->rx_ring[rx_queue_idx].desc[i];
10721079

10731080
/*skb->dev = dev; */
10741081

0 commit comments

Comments
 (0)