diff mbox series

wifi: ath11k: fix memory leak in ath11k_xxx_remove()

Message ID 20240315014307.3132980-1-quic_miaoqing@quicinc.com (mailing list archive)
State Deferred
Delegated to: Kalle Valo
Headers show
Series wifi: ath11k: fix memory leak in ath11k_xxx_remove() | expand

Commit Message

Miaoqing Pan March 15, 2024, 1:43 a.m. UTC
The firmware memory was allocated in ath11k_pci_probe() or
ath11k_ahb_probe(), but not freed in ath11k_xxx_remove() in case
ATH11K_FLAG_QMI_FAIL bit is set. So call ath11k_fw_destroy() to
free the memory.

Found while fixing the same problem in ath12k:
https://lore.kernel.org/linux-wireless/20240314012746.2729101-1-quic_miaoqing@quicinc.com

No functional changes, compile tested only.

Signed-off-by: Miaoqing Pan <quic_miaoqing@quicinc.com>
---
 drivers/net/wireless/ath/ath11k/ahb.c | 1 +
 drivers/net/wireless/ath/ath11k/fw.c  | 1 +
 drivers/net/wireless/ath/ath11k/pci.c | 1 +
 3 files changed, 3 insertions(+)

Comments

Jeff Johnson March 18, 2024, 7:41 p.m. UTC | #1
On 3/14/2024 6:43 PM, Miaoqing Pan wrote:
> The firmware memory was allocated in ath11k_pci_probe() or
> ath11k_ahb_probe(), but not freed in ath11k_xxx_remove() in case
> ATH11K_FLAG_QMI_FAIL bit is set. So call ath11k_fw_destroy() to
> free the memory.
> 
> Found while fixing the same problem in ath12k:
> https://lore.kernel.org/linux-wireless/20240314012746.2729101-1-quic_miaoqing@quicinc.com
> 
> No functional changes, compile tested only.
> 
> Signed-off-by: Miaoqing Pan <quic_miaoqing@quicinc.com>
> ---
>  drivers/net/wireless/ath/ath11k/ahb.c | 1 +
>  drivers/net/wireless/ath/ath11k/fw.c  | 1 +
>  drivers/net/wireless/ath/ath11k/pci.c | 1 +

My Qualcomm Innovation Center copyright checker reports:
drivers/net/wireless/ath/ath11k/ahb.c copyright missing 2024
drivers/net/wireless/ath/ath11k/fw.c copyright missing 2024

Kalle, do you want a respin or will you handle this?
With copyrights fixed you can add my:
Acked-by: Jeff Johnson <quic_jjohnson@quicinc.com>
diff mbox series

Patch

diff --git a/drivers/net/wireless/ath/ath11k/ahb.c b/drivers/net/wireless/ath/ath11k/ahb.c
index 7c0a23517949..6bc4e55c6c2b 100644
--- a/drivers/net/wireless/ath/ath11k/ahb.c
+++ b/drivers/net/wireless/ath/ath11k/ahb.c
@@ -1259,6 +1259,7 @@  static void ath11k_ahb_remove(struct platform_device *pdev)
 		ath11k_ahb_power_down(ab);
 		ath11k_debugfs_soc_destroy(ab);
 		ath11k_qmi_deinit_service(ab);
+		ath11k_fw_destroy(ab);
 		goto qmi_fail;
 	}
 
diff --git a/drivers/net/wireless/ath/ath11k/fw.c b/drivers/net/wireless/ath/ath11k/fw.c
index 4e36292a79db..22327d5f9680 100644
--- a/drivers/net/wireless/ath/ath11k/fw.c
+++ b/drivers/net/wireless/ath/ath11k/fw.c
@@ -166,3 +166,4 @@  void ath11k_fw_destroy(struct ath11k_base *ab)
 {
 	release_firmware(ab->fw.fw);
 }
+EXPORT_SYMBOL(ath11k_fw_destroy);
diff --git a/drivers/net/wireless/ath/ath11k/pci.c b/drivers/net/wireless/ath/ath11k/pci.c
index be9d2c69cc41..6099d02d5f65 100644
--- a/drivers/net/wireless/ath/ath11k/pci.c
+++ b/drivers/net/wireless/ath/ath11k/pci.c
@@ -973,6 +973,7 @@  static void ath11k_pci_remove(struct pci_dev *pdev)
 		ath11k_pci_power_down(ab);
 		ath11k_debugfs_soc_destroy(ab);
 		ath11k_qmi_deinit_service(ab);
+		ath11k_fw_destroy(ab);
 		goto qmi_fail;
 	}