wifi: ath10k: Do not free the caller's skb when HL TX expands the headroom
Subsystems (2)
PATCH 1/1 wifi: ath10k: Do not free the caller's skb when HL TX expands the headroom
When the skb has too little headroom, ath10k_htt_tx_hl() copies it with skb_realloc_headroom() and frees the original. If the copy fails, or a later step fails, the function returns an error and ath10k_mac_tx_submit() frees the original skb again with ieee80211_free_txskb().
Expand the headroom of the same skb with pskb_expand_head() instead, so the caller still owns it on every error path.
---
Notes:
Bug was found by kbound, an internal static analysis prototype. The fix was written with the help of Claude Opus 5.5.
Compile-tested only (x86_64 and arm64 allmodconfig, W=1, sparse): I do not have an SDIO or USB ath10k device.
drivers/net/wireless/ath/ath10k/htt_tx.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/net/wireless/ath/ath10k/htt_tx.c +4 -7
@@ -1276,7 +1276,6 @@ static int ath10k_htt_tx_hl(struct ath10k_htt *htt, enum ath10k_hw_txrx_mode txmstruct htt_cmd_hdr *cmd_hdr;struct htt_data_tx_desc *tx_desc;struct ath10k_skb_cb *skb_cb =ATH10K_SKB_CB (msdu); -struct sk_buff *tmp_skb;bool is_eth = (txmode ==ATH10K_HW_TXRX_ETHERNET );u8 vdev_id =ath10k_htt_tx_get_vdev_id (ar, msdu);u8 tid =ath10k_htt_tx_get_tid (msdu, is_eth);
@@ -1330,16 +1329,14 @@ static int ath10k_htt_tx_hl(struct ath10k_htt *htt, enum ath10k_hw_txrx_mode txm* and realloc the skb if it does not have enough headroom. */ if (skb_headroom (msdu) <HTT_TX_HL_NEEDED_HEADROOM ) { - tmp_skb = msdu; -ath10k_dbg (htt->ar,ATH10K_DBG_HTT ,"Not enough headroom in skb. Current headroom: %u, needed: %u. Reallocating...\n" ,skb_headroom (msdu),HTT_TX_HL_NEEDED_HEADROOM ); - msdu =skb_realloc_headroom (msdu,HTT_TX_HL_NEEDED_HEADROOM ); -kfree_skb (tmp_skb); -if (!msdu) { + res =pskb_expand_head (msdu, +HTT_TX_HL_NEEDED_HEADROOM -skb_headroom (msdu), +0 ,GFP_ATOMIC ); +if (res) {ath10k_warn (htt->ar,"htt hl tx: Unable to realloc skb!\n" ); - res = -ENOMEM ; goto out; } }
base-commit: b1ed5a45b994a6473ca1cf34f35a1bf87f1d8e2a
Signature · 1 line
2.53.0