diff mbox series

[wireless-next,02/15] wifi: mac80211: Fix uninitialized variable with __free() in ieee80211_ml_epcs()

Message ID 20250609213231.eeacd3738a7b.I0f876fa1359daeec47ab3aef098255a9c23efd70@changeid
State New
Headers show
Series wifi: cfg80211/mac80211: updates - 2025-06-09 | expand

Commit Message

Miri Korenblit June 9, 2025, 6:35 p.m. UTC
From: Pagadala Yesu Anjaneyulu <pagadala.yesu.anjaneyulu@intel.com>

The cleanup attribute runs kfree() when the variable goes out of scope.
There is a possibility that the link_elems variable is uninitialized
if the loop ends before an assignment is made to this variable.
This leads to uninitialized variable bug.

Fix this by assigning link_elems to NULL.

Signed-off-by: Pagadala Yesu Anjaneyulu <pagadala.yesu.anjaneyulu@intel.com>
Reviewed-by: Ilan Peer <ilan.peer@intel.com>
Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
---
 net/mac80211/mlme.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index b84150dbfe8c..d8953a855ab4 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -10701,8 +10701,8 @@  static void ieee80211_ml_epcs(struct ieee80211_sub_if_data *sdata,
 	 */
 	for_each_mle_subelement(sub, (const u8 *)elems->ml_epcs,
 				elems->ml_epcs_len) {
+		struct ieee802_11_elems *link_elems __free(kfree) = NULL;
 		struct ieee80211_link_data *link;
-		struct ieee802_11_elems *link_elems __free(kfree);
 		u8 *pos = (void *)sub->data;
 		u16 control;
 		ssize_t len;