wifi: rtw88: Free the H2C skb if PCI TX fails
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.
--- drivers/net/wireless/realtek/rtw88/pci.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/realtek/rtw88/pci.c +1 -0
@@ -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
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 callingrtw_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
Signed-off-by Wanhui Fu <[email protected]>---
Either way it looks good to me,
Best regards,
Luka Gejak