# \[PATCH 07/12\] iwlwifi: mvm: fix a memory leak in iwl\_mvm\_mac\_ctxt\_beacon\_changed

- From: Luca Coelho \<hidden\>
- Date: 2021-08-02 14:28:40 
- List: linux-wireless
- Page: https://ratatoskr.run/linux-wireless/2021/08/15768361
- Thread: https://ratatoskr.run/linux-wireless/2021/08/15768354/t.md

```text
From: Zhang Qilong <redacted>

If beacon_inject_active is true, we will return without freeing
beacon.  Fid that by freeing it before returning.

Signed-off-by: Zhang Qilong <redacted>
[reworded the commit message]
Signed-off-by: Luca Coelho <redacted>
---
 drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
index 76a658cb5493..2fbc1a3bbdca 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
@@ -1008,8 +1008,10 @@ int iwl_mvm_mac_ctxt_beacon_changed(struct iwl_mvm *mvm,
 		return -ENOMEM;
 
 #ifdef CONFIG_IWLWIFI_DEBUGFS
-	if (mvm->beacon_inject_active)
+	if (mvm->beacon_inject_active) {
+		dev_kfree_skb(beacon);
 		return -EBUSY;
+	}
 #endif
 
 	ret = iwl_mvm_mac_ctxt_send_beacon(mvm, vif, beacon);
-- 
2.32.0

```
