Skip to contentSkip to conversation

wifi: mac80211: fix NULL pointer dereference in ieee80211_mesh_build_beacon()

PATCH In review Jeongjun Park 2 participants 2 messages Jan 19 – Jan 20 mac80211

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wifi: mac80211: fix NULL pointer dereference in ieee80211_mesh_build_beacon()

NULL pointer dereference bug occurs because ieee80211_mesh_build_beacon() does not check the return value of ieee80211_get_sband().

Therefore, we need to add a return value check to prevent this.

Reported-by [email protected]
Fixes 147ceae20534 ("wifi: mac80211: simplify adding supported rates")
---
 net/mac80211/mesh.c | 2 ++
 1 file changed, 2 insertions(+)
net/mac80211/mesh.c +2 -0
index 68901f1def0d..eb3a346226bd 100644
@@ -964,6 +964,8 @@ ieee80211_mesh_build_beacon(struct ieee80211_if_mesh *ifmsh)
 	sdata = container_of(ifmsh, struct ieee80211_sub_if_data, u.mesh);
 
 	sband = ieee80211_get_sband(sdata);
+	if (!sband)
+		return -EINVAL;
 
 	ie_len_he_cap = ieee80211_ie_len_he_cap(sdata);
 	ie_len_eht_cap = ieee80211_ie_len_eht_cap(sdata);

--

maintainer
#1 lore raw
Quoted 4 lines · Jeongjun Park

NULL pointer dereference bug occurs because ieee80211_mesh_build_beacon() does not check the return value of ieee80211_get_sband().

Therefore, we need to add a return value check to prevent this.

No we don't, please try to understand the code, and why it can even get here when the mesh interface isn't operating.

johannes