wifi: rtlwifi: fix possible skb memory leak in _rtl_pci_init_one_rxdesc()

When `dma_mapping_error()` is true, if a new `skb` has been allocated,
then it must be de-allocated.

Compile tested only

Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20250613074014.69856-2-fourier.thomas@gmail.com
This commit is contained in:
Thomas Fourier 2025-06-13 09:38:36 +02:00 committed by Ping-Ke Shih
parent 9b550b98f0
commit 76b3e5078d

View File

@ -572,8 +572,11 @@ static int _rtl_pci_init_one_rxdesc(struct ieee80211_hw *hw,
dma_map_single(&rtlpci->pdev->dev, skb_tail_pointer(skb),
rtlpci->rxbuffersize, DMA_FROM_DEVICE);
bufferaddress = *((dma_addr_t *)skb->cb);
if (dma_mapping_error(&rtlpci->pdev->dev, bufferaddress))
if (dma_mapping_error(&rtlpci->pdev->dev, bufferaddress)) {
if (!new_skb)
kfree_skb(skb);
return 0;
}
rtlpci->rx_ring[rxring_idx].rx_buf[desc_idx] = skb;
if (rtlpriv->use_new_trx_flow) {
/* skb->cb may be 64 bit address */