mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drive/realtek/rtlwifi: fix possible memory leak
@ 2025-06-12  9:07 Thomas Fourier
  2025-06-12 22:45 ` kernel test robot
  2025-06-13  0:41 ` Ping-Ke Shih
  0 siblings, 2 replies; 5+ messages in thread
From: Thomas Fourier @ 2025-06-12  9:07 UTC (permalink / raw)
  Cc: Thomas Fourier, Ping-Ke Shih, linux-wireless, linux-kernel

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

Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
---
 drivers/net/wireless/realtek/rtlwifi/pci.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtlwifi/pci.c b/drivers/net/wireless/realtek/rtlwifi/pci.c
index 898f597f70a9..f754f1c3f783 100644
--- a/drivers/net/wireless/realtek/rtlwifi/pci.c
+++ b/drivers/net/wireless/realtek/rtlwifi/pci.c
@@ -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 */
-- 
2.43.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-06-16  3:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-12  9:07 [PATCH] drive/realtek/rtlwifi: fix possible memory leak Thomas Fourier
2025-06-12 22:45 ` kernel test robot
2025-06-13  0:41 ` Ping-Ke Shih
2025-06-13  7:38   ` [PATCH rtw-next] wifi: rtlwifi: fix possible skb memory leak in _rtl_pci_init_one_rxdesc() Thomas Fourier
2025-06-16  3:56     ` Ping-Ke Shih

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®