From 2ff5eea9f7a5ad18e1ac8f48c29786083d4abaa3 Mon Sep 17 00:00:00 2001
From: Sarika Sharma <quic_sarishar@quicinc.com>
Date: Thu, 14 Mar 2024 08:44:09 +0530
Subject: [PATCH] wifi: ath11k: correctly free skb using ieee80211_free_txskb()

While freeing skb in tx completion path for status reinject, inspect
or vdevid mismatch, dev_kfree_skb_any() is used but when a function
is using functions from mac80211 to free an skb then it should do
it consistently and not switch to the generic dev_kfree_skb_any.
Otherwise, mac80211 will not be aware of the freed skb and thus
not clean up related information in its internal data structures.

Hence fix the issue by properly using ieee80211_free_txskb().

Signed-off-by: Sarika Sharma <quic_sarishar@quicinc.com>
---
 drivers/net/wireless/ath/ath11k/dp_tx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/drivers/net/wireless/ath/ath11k/dp_tx.c
+++ b/drivers/net/wireless/ath/ath11k/dp_tx.c
@@ -384,9 +384,13 @@ static void ath11k_dp_tx_free_txbuf(stru
 	skb_cb = ATH11K_SKB_CB(msdu);
 
 	dma_unmap_single(ab->dev, skb_cb->paddr, msdu->len, DMA_TO_DEVICE);
-	dev_kfree_skb_any(msdu);
 
 	ar = ab->pdevs[mac_id].ar;
+	if (ab->stats_disable)
+		dev_kfree_skb_any(msdu);
+	else
+		ieee80211_free_txskb(ar->hw, msdu);
+
 	if (atomic_dec_and_test(&ar->dp.num_tx_pending))
 		wake_up(&ar->dp.tx_empty_waitq);
 }
