Skip to contentSkip to conversation

wifi: rtlwifi: fix possible skb memory leak in `_rtl_pci_rx_interrupt()`.

PATCH In review Thomas Fourier 2 participants 3 messages Jun 16, 2025 – Jun 24, 2025 Realtek wireless driver (rtlwifi family)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: rtlwifi: fix possible skb memory leak in `_rtl_pci_rx_interrupt()`.

The function _rtl_pci_init_one_rxdesc() can fail even when the new skb is passed because of a DMA mapping error. If it fails, the skb is not saved in the rx ringbuffer and thus lost.

Compile tested only

---
 drivers/net/wireless/realtek/rtlwifi/pci.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
drivers/net/wireless/realtek/rtlwifi/pci.c +12 -6
index 472072630f8d..d080469264cf 100644
@@ -805,13 +805,19 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
 		skb = new_skb;
 no_new:
 		if (rtlpriv->use_new_trx_flow) {
-			_rtl_pci_init_one_rxdesc(hw, skb, (u8 *)buffer_desc,
-						 rxring_idx,
-						 rtlpci->rx_ring[rxring_idx].idx);
+			if (!_rtl_pci_init_one_rxdesc(hw, skb, (u8 *)buffer_desc,
+						      rxring_idx,
+						      rtlpci->rx_ring[rxring_idx].idx)) {
+				if (new_skb)
+					dev_kfree_skb_any(skb);
+			}
 		} else {
-			_rtl_pci_init_one_rxdesc(hw, skb, (u8 *)pdesc,
-						 rxring_idx,
-						 rtlpci->rx_ring[rxring_idx].idx);
+			if (!_rtl_pci_init_one_rxdesc(hw, skb, (u8 *)pdesc,
+						      rxring_idx,
+						      rtlpci->rx_ring[rxring_idx].idx)) {
+				if (new_skb)
+					dev_kfree_skb_any(skb);
+			}
 			if (rtlpci->rx_ring[rxring_idx].idx ==
 			    rtlpci->rxringcount - 1)
 				rtlpriv->cfg->ops->set_desc(hw, (u8 *)pdesc,
Signature · 1 line
2.43.0
maintainer
#2 lore raw
In reply to Thomas Fourier
Quoted 8 lines · Thomas Fourier

The function _rtl_pci_init_one_rxdesc() can fail even when the new skb is passed because of a DMA mapping error. If it fails, the skb is not saved in the rx ringbuffer and thus lost.

Compile tested only

1 patch(es) applied to rtw-next branch of rtw.git, thanks.

44c0e191004f wifi: rtlwifi: fix possible skb memory leak in _rtl_pci_rx_interrupt().

---
https://github.com/pkshih/rtw.git