Skip to contentSkip to conversation

wifi: rtw88: Free the H2C skb if PCI TX fails

PATCH In review Wanhui Fu 2 participants 2 messages Dec 4 Realtek wireless driver (rtw88)

lore
Share & tools
lore

Wanhui Fu

author
#0 lore raw

PATCH 1/1 wifi: rtw88: Free the H2C skb if PCI TX fails

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")
---
 drivers/net/wireless/realtek/rtw88/pci.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/wireless/realtek/rtw88/pci.c +1 -0
index 66d2e5f51444..025b9c1502b2 100644
@@ -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;
 	}
 
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw

Hi Wanhui,

patches for rtw next should use [PATCH rtw-next] instead of plain [PATCH].

Quoted 6 lines · Wanhui Fu

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.

Quoted 6 lines

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")

This should cc stable in my opinion.

Quoted 2 lines

---

Either way it looks good to me,

Best regards,
Luka Gejak