diff mbox series

[wireless,3/8] wifi: mac80211: mlme: fix memory leak

Message ID 20240418105220.458421e3bbff.Icb5b84cba3ea420794cf009cf18ec3d76e434736@changeid (mailing list archive)
State Accepted
Delegated to: Johannes Berg
Headers show
Series [wireless,1/8] wifi: mac80211: fix idle calculation with multi-link | expand

Commit Message

Johannes Berg April 18, 2024, 8:52 a.m. UTC
From: Johannes Berg <johannes.berg@intel.com>

When re-parsing the elements here (with changed mode), free
the original ones first to avoid leaking memory.

Fixes: 310c8387c638 ("wifi: mac80211: clean up connection process")
Reviewed-by: Miriam Rachel Korenblit <miriam.rachel.korenblit@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 net/mac80211/mlme.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 98cb475a14c8..6fa3752b740e 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -753,8 +753,10 @@  ieee80211_determine_chan_mode(struct ieee80211_sub_if_data *sdata,
 	}
 
 	/* the mode can only decrease, so this must terminate */
-	if (ap_mode != conn->mode)
+	if (ap_mode != conn->mode) {
+		kfree(elems);
 		goto again;
+	}
 
 	mlme_link_id_dbg(sdata, link_id,
 			 "connecting with %s mode, max bandwidth %d MHz\n",