Skip to content

Commit a398185

Browse files
miaoqing-quicgregkh
authored andcommitted
wifi: ath11k: fix memory leak in ath11k_xxx_remove()
[ Upstream commit efb24b1 ] 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 Tested-on: WCN6855 hw2.1 PCI WLAN.HSP.1.1-04546-QCAHSPSWPL_V1_V2_SILICONZ_IOE-1 Signed-off-by: Miaoqing Pan <quic_miaoqing@quicinc.com> Reviewed-by: Aditya Kumar Singh <aditya.kumar.singh@oss.qualcomm.com> Link: https://patch.msgid.link/20250123084948.1124357-1-quic_miaoqing@quicinc.com Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent b92c517 commit a398185

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

drivers/net/wireless/ath/ath11k/ahb.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: BSD-3-Clause-Clear
22
/*
33
* Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
4-
* Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved.
4+
* Copyright (c) 2022-2025 Qualcomm Innovation Center, Inc. All rights reserved.
55
*/
66

77
#include <linux/module.h>
@@ -1290,6 +1290,7 @@ static void ath11k_ahb_remove(struct platform_device *pdev)
12901290
ath11k_core_deinit(ab);
12911291

12921292
qmi_fail:
1293+
ath11k_fw_destroy(ab);
12931294
ath11k_ahb_free_resources(ab);
12941295
}
12951296

@@ -1309,6 +1310,7 @@ static void ath11k_ahb_shutdown(struct platform_device *pdev)
13091310
ath11k_core_deinit(ab);
13101311

13111312
free_resources:
1313+
ath11k_fw_destroy(ab);
13121314
ath11k_ahb_free_resources(ab);
13131315
}
13141316

drivers/net/wireless/ath/ath11k/core.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: BSD-3-Clause-Clear
22
/*
33
* Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
4-
* Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
4+
* Copyright (c) 2021-2025 Qualcomm Innovation Center, Inc. All rights reserved.
55
*/
66

77
#include <linux/module.h>
@@ -2214,7 +2214,6 @@ void ath11k_core_deinit(struct ath11k_base *ab)
22142214
ath11k_hif_power_down(ab);
22152215
ath11k_mac_destroy(ab);
22162216
ath11k_core_soc_destroy(ab);
2217-
ath11k_fw_destroy(ab);
22182217
}
22192218
EXPORT_SYMBOL(ath11k_core_deinit);
22202219

drivers/net/wireless/ath/ath11k/fw.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: BSD-3-Clause-Clear
22
/*
3-
* Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
3+
* Copyright (c) 2022-2025 Qualcomm Innovation Center, Inc. All rights reserved.
44
*/
55

66
#include "core.h"
@@ -166,3 +166,4 @@ void ath11k_fw_destroy(struct ath11k_base *ab)
166166
{
167167
release_firmware(ab->fw.fw);
168168
}
169+
EXPORT_SYMBOL(ath11k_fw_destroy);

drivers/net/wireless/ath/ath11k/pci.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: BSD-3-Clause-Clear
22
/*
33
* Copyright (c) 2019-2020 The Linux Foundation. All rights reserved.
4-
* Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
4+
* Copyright (c) 2021-2025 Qualcomm Innovation Center, Inc. All rights reserved.
55
*/
66

77
#include <linux/module.h>
@@ -981,6 +981,7 @@ static void ath11k_pci_remove(struct pci_dev *pdev)
981981
ath11k_core_deinit(ab);
982982

983983
qmi_fail:
984+
ath11k_fw_destroy(ab);
984985
ath11k_mhi_unregister(ab_pci);
985986

986987
ath11k_pcic_free_irq(ab);

0 commit comments

Comments
 (0)