mac80211: ath11k: sync with upstream
[openwrt/openwrt.git] / package / kernel / mac80211 / patches / ath11k / 0085-wifi-ath11k-fix-memory-leak-in-WMI-firmware-stats.patch
1 From 6aafa1c2d3e3fea2ebe84c018003f2a91722e607 Mon Sep 17 00:00:00 2001
2 From: P Praneesh <quic_ppranees@quicinc.com>
3 Date: Tue, 6 Jun 2023 14:41:28 +0530
4 Subject: [PATCH] wifi: ath11k: fix memory leak in WMI firmware stats
5
6 Memory allocated for firmware pdev, vdev and beacon statistics
7 are not released during rmmod.
8
9 Fix it by calling ath11k_fw_stats_free() function before hardware
10 unregister.
11
12 While at it, avoid calling ath11k_fw_stats_free() while processing
13 the firmware stats received in the WMI event because the local list
14 is getting spliced and reinitialised and hence there are no elements
15 in the list after splicing.
16
17 Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1
18
19 Signed-off-by: P Praneesh <quic_ppranees@quicinc.com>
20 Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com>
21 Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
22 Link: https://lore.kernel.org/r/20230606091128.14202-1-quic_adisi@quicinc.com
23 ---
24 drivers/net/wireless/ath/ath11k/mac.c | 1 +
25 drivers/net/wireless/ath/ath11k/wmi.c | 5 +++++
26 2 files changed, 6 insertions(+)
27
28 --- a/drivers/net/wireless/ath/ath11k/mac.c
29 +++ b/drivers/net/wireless/ath/ath11k/mac.c
30 @@ -9792,6 +9792,7 @@ void ath11k_mac_destroy(struct ath11k_ba
31 if (!ar)
32 continue;
33
34 + ath11k_fw_stats_free(&ar->fw_stats);
35 ieee80211_free_hw(ar->hw);
36 pdev->ar = NULL;
37 }
38 --- a/drivers/net/wireless/ath/ath11k/wmi.c
39 +++ b/drivers/net/wireless/ath/ath11k/wmi.c
40 @@ -8119,6 +8119,11 @@ complete:
41 rcu_read_unlock();
42 spin_unlock_bh(&ar->data_lock);
43
44 + /* Since the stats's pdev, vdev and beacon list are spliced and reinitialised
45 + * at this point, no need to free the individual list.
46 + */
47 + return;
48 +
49 free:
50 ath11k_fw_stats_free(&stats);
51 }