[PATCH] wifi: ath6kl: Fix potential firmware leaks on initialization failure

From: Guangshuo Li

Date: Fri Nov 20 2026 - 12:35:34 EST


Firmware loading can leave allocated images in the core before a later
initialization step fails. The initialization error path destroys the
core without releasing these images.

Share firmware cleanup between the initialization error path and normal
teardown.

This issue was found by our static analysis tool under development.

Fixes: bdcd81707973 ("Add ath6kl cleaned up driver")
Signed-off-by: Guangshuo Li <liguangshuo@xxxxxxxxxxxxxxx>
---
drivers/net/wireless/ath/ath6kl/core.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/ath/ath6kl/core.c b/drivers/net/wireless/ath/ath6kl/core.c
index 648110cd313f..fec0e1ad9752 100644
--- a/drivers/net/wireless/ath/ath6kl/core.c
+++ b/drivers/net/wireless/ath/ath6kl/core.c
@@ -63,6 +63,15 @@ void ath6kl_core_rx_complete(struct ath6kl *ar, struct sk_buff *skb, u8 pipe)
}
EXPORT_SYMBOL(ath6kl_core_rx_complete);

+static void ath6kl_core_free_firmwares(struct ath6kl *ar)
+{
+ kfree(ar->fw_board);
+ kfree(ar->fw_otp);
+ vfree(ar->fw);
+ kfree(ar->fw_patch);
+ kfree(ar->fw_testscript);
+}
+
int ath6kl_core_init(struct ath6kl *ar, enum ath6kl_htc_type htc_type)
{
struct ath6kl_bmi_target_info targ_info;
@@ -123,8 +132,6 @@ int ath6kl_core_init(struct ath6kl *ar, enum ath6kl_htc_type htc_type)
if (ret)
goto err_htc_cleanup;

- /* FIXME: we should free all firmwares in the error cases below */
-
/*
* Backwards compatibility support for older ar6004 firmware images
* which do not set these feature flags.
@@ -252,6 +259,7 @@ int ath6kl_core_init(struct ath6kl *ar, enum ath6kl_htc_type htc_type)
clear_bit(WMI_ENABLED, &ar->flag);
ar->wmi = NULL;
err_htc_cleanup:
+ ath6kl_core_free_firmwares(ar);
ath6kl_htc_cleanup(ar->htc_target);
err_power_off:
ath6kl_hif_power_off(ar);
@@ -346,11 +354,7 @@ void ath6kl_core_cleanup(struct ath6kl *ar)

ath6kl_debug_cleanup(ar);

- kfree(ar->fw_board);
- kfree(ar->fw_otp);
- vfree(ar->fw);
- kfree(ar->fw_patch);
- kfree(ar->fw_testscript);
+ ath6kl_core_free_firmwares(ar);

ath6kl_cfg80211_cleanup(ar);
}

base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4