Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH rtw-next v2] wifi: rtw88: Free the H2C skb if PCI TX fails
@ 2026-12-05 14:13 Wanhui Fu
  2026-12-06  2:52 ` Ping-Ke Shih
  0 siblings, 1 reply; 2+ messages in thread
From: Wanhui Fu @ 2026-12-05 14:13 UTC (permalink / raw)
  To: pkshih, sgruszka, yhchuang, briannorris, kvalo
  Cc: linux-wireless, Wanhui Fu, stable, Luka Gejak

rtw_tx_write_data_h2c_get() allocates an skb before calling
rtw_pci_tx_write_data(). If the ring is full or the mapping
fails, rtw_pci_tx_write_data() returns without queuing the
skb, causing a memory leak.

Free the skb if rtw_pci_tx_write_data() fails.

Found it by self-developed static analysis tool and compile-
test passed.

Fixes: e3037485c68e ("rtw88: new Realtek 802.11ac driver")
Cc: stable@vger.kernel.org
Signed-off-by: Wanhui Fu <fuwh1120@163.com>
Reviewed-by: Luka Gejak <luka.gejak@linux.dev>
---
Changes in v2:
 - Add cc to stable and rtw-next header. Thanks, Luka!
---
 drivers/net/wireless/realtek/rtw88/pci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/realtek/rtw88/pci.c b/drivers/net/wireless/realtek/rtw88/pci.c
index 66d2e5f51444..025b9c1502b2 100644
--- a/drivers/net/wireless/realtek/rtw88/pci.c
+++ b/drivers/net/wireless/realtek/rtw88/pci.c
@@ -906,6 +906,7 @@ static int rtw_pci_write_data_h2c(struct rtw_dev *rtwdev, u8 *buf, u32 size)
 	ret = rtw_pci_tx_write_data(rtwdev, &pkt_info, skb, RTW_TX_QUEUE_H2C);
 	if (ret) {
 		rtw_err(rtwdev, "failed to write h2c data\n");
+		dev_kfree_skb_any(skb);
 		return ret;
 	}
 
-- 
2.25.1


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

* RE: [PATCH rtw-next v2] wifi: rtw88: Free the H2C skb if PCI TX fails
  2026-12-05 14:13 [PATCH rtw-next v2] wifi: rtw88: Free the H2C skb if PCI TX fails Wanhui Fu
@ 2026-12-06  2:52 ` Ping-Ke Shih
  0 siblings, 0 replies; 2+ messages in thread
From: Ping-Ke Shih @ 2026-12-06  2:52 UTC (permalink / raw)
  To: Wanhui Fu, sgruszka@redhat.com, yhchuang@realtek.com,
	briannorris@chromium.org, kvalo@kernel.org
  Cc: linux-wireless@vger.kernel.org, stable@vger.kernel.org,
	Luka Gejak

Wanhui Fu <fuwh1120@163.com> wrote:
> rtw_tx_write_data_h2c_get() allocates an skb before calling
> rtw_pci_tx_write_data(). If the ring is full or the mapping
> fails, rtw_pci_tx_write_data() returns without queuing the
> skb, causing a memory leak.
> 
> Free the skb if rtw_pci_tx_write_data() fails.
> 
> Found it by self-developed static analysis tool and compile-
> test passed.
> 
> Fixes: e3037485c68e ("rtw88: new Realtek 802.11ac driver")

Should be 

Fixes: aaab5d0e6737 ("rtw88: kick off TX packets once for higher efficiency")

No need to resend because of this.

> Cc: stable@vger.kernel.org
> Signed-off-by: Wanhui Fu <fuwh1120@163.com>
> Reviewed-by: Luka Gejak <luka.gejak@linux.dev>

Acked-by: Ping-Ke Shih <pkshih@realtek.com>



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

end of thread, other threads:[~2026-12-06  2:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-05 14:13 [PATCH rtw-next v2] wifi: rtw88: Free the H2C skb if PCI TX fails Wanhui Fu
2026-12-06  2:52 ` 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