[PATCH rtw-next v2 3/7] wifi: rtw89: usb: use ieee80211_free_txskb() where appropriate

Fedor Pchelkin
2025-10-02T20:09:25Z

rtw89_usb_ops_tx_kick_off() may need to release skb if a failure occurs.
It operates mainly on skbs coming from the core wireless stack and the
ones containing firmware commands.

Use ieee80211_free_txskb() for the former case.

Suggested-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
---

drivers/net/wireless/realtek/rtw89/usb.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw89/usb.c b/drivers/net/wireless/realtek/rtw89/usb.c
index 512a46dd9d06..655e8437d62e 100644
--- a/drivers/net/wireless/realtek/rtw89/usb.c
+++ b/drivers/net/wireless/realtek/rtw89/usb.c
@@ -278,6 +278,15 @@ static int rtw89_usb_write_port(struct rtw89_dev *rtwdev, u8 ch_dma,
return ret;
}

+static void rtw89_usb_tx_free_skb(struct rtw89_dev *rtwdev, u8 txch,
+ struct sk_buff *skb)
+{
+ if (txch == RTW89_TXCH_CH12)
+ dev_kfree_skb_any(skb);
+ else
+ ieee80211_free_txskb(rtwdev->hw, skb);
+}
+
static void rtw89_usb_ops_tx_kick_off(struct rtw89_dev *rtwdev, u8 txch)
{
struct rtw89_usb *rtwusb = rtw89_usb_priv(rtwdev);
@@ -292,7 +301,7 @@ static void rtw89_usb_ops_tx_kick_off(struct rtw89_dev *rtwdev, u8 txch)

txcb = kmalloc(sizeof(*txcb), GFP_ATOMIC);
if (!txcb) {
- dev_kfree_skb_any(skb);
+ rtw89_usb_tx_free_skb(rtwdev, txch, skb);
continue;
}

@@ -311,7 +320,7 @@ static void rtw89_usb_ops_tx_kick_off(struct rtw89_dev *rtwdev, u8 txch)

skb_dequeue(&txcb->tx_ack_queue);
kfree(txcb);
- dev_kfree_skb_any(skb);
+ rtw89_usb_tx_free_skb(rtwdev, txch, skb);
}
}
}
--
2.51.0