wifi: ath11k: fix memory leak in WMI firmware stats
authorP Praneesh <quic_ppranees@quicinc.com>
Tue, 6 Jun 2023 09:11:28 +0000 (14:41 +0530)
committerKalle Valo <quic_kvalo@quicinc.com>
Tue, 13 Jun 2023 09:14:53 +0000 (12:14 +0300)
Memory allocated for firmware pdev, vdev and beacon statistics
are not released during rmmod.

Fix it by calling ath11k_fw_stats_free() function before hardware
unregister.

While at it, avoid calling ath11k_fw_stats_free() while processing
the firmware stats received in the WMI event because the local list
is getting spliced and reinitialised and hence there are no elements
in the list after splicing.

Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.7.0.1-01744-QCAHKSWPL_SILICONZ-1

Signed-off-by: P Praneesh <quic_ppranees@quicinc.com>
Signed-off-by: Aditya Kumar Singh <quic_adisi@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20230606091128.14202-1-quic_adisi@quicinc.com
drivers/net/wireless/ath/ath11k/mac.c
drivers/net/wireless/ath/ath11k/wmi.c

index 32d958b66ba4d1b5ff6c6f08f2df18d6fc0e41d4..8c77ade49437fff1b94d4ef266fe775c678e8c40 100644 (file)
@@ -9792,6 +9792,7 @@ void ath11k_mac_destroy(struct ath11k_base *ab)
                if (!ar)
                        continue;
 
+               ath11k_fw_stats_free(&ar->fw_stats);
                ieee80211_free_hw(ar->hw);
                pdev->ar = NULL;
        }
index 6dc2109557bcd70adaaa4c6baec48f38d6a530ab..23ad6825e5be584fd37d6c9d553d7a11779236e8 100644 (file)
@@ -8198,6 +8198,11 @@ complete:
        rcu_read_unlock();
        spin_unlock_bh(&ar->data_lock);
 
+       /* Since the stats's pdev, vdev and beacon list are spliced and reinitialised
+        * at this point, no need to free the individual list.
+        */
+       return;
+
 free:
        ath11k_fw_stats_free(&stats);
 }