From: Zhao Li <enderaoelyther@gmail.com>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: John Crispin <john@phrozen.org>,
Aloka Dixit <quic_alokad@quicinc.com>,
linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2] wifi: nl80211: clean up color-change beacon data on errors
Date: Fri, 31 Jul 2026 12:02:44 +0800 [thread overview]
Message-ID: <20260731120244.82628-1-enderaoelyther@gmail.com> (raw)
In-Reply-To: <450be3831c5e0234c309d4c04641a42c6ac4f2b0.camel@sipsolutions.net>
nl80211_color_change() calls nl80211_parse_beacon() for the beacon_next
template, which can allocate params.beacon_next.mbssid_ies and .rnr_ies.
A parsing failure returned directly instead of using the out: cleanup,
leaking any allocations completed before the error.
Allocate the nested attribute table before parsing beacon_next. Its
allocation failure can then return before beacon data exists, while a
later parsing failure uses out: to release the parsed data.
Fixes: dc1e3cb8da8b ("nl80211: MBSSID and EMA support in AP mode")
Assisted-by: Codex:gpt-5
Assisted-by: Claude:opus-4.8
Assisted-by: Kimi:K3
Signed-off-by: Zhao Li <enderaoelyther@gmail.com>
---
Changes in v2:
- Allocate the attribute table before parsing beacon_next, as suggested by
Johannes.
net/wireless/nl80211.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 5adcb6bd0fc5..755f8fe711fb 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -18750,15 +18750,15 @@ static int nl80211_color_change(struct sk_buff *skb, struct genl_info *info)
if (!wdev->links[params.link_id].ap.beacon_interval)
return -EINVAL;
+ tb = kzalloc_objs(*tb, NL80211_ATTR_MAX + 1);
+ if (!tb)
+ return -ENOMEM;
+
err = nl80211_parse_beacon(rdev, info->attrs, ¶ms.beacon_next,
wdev->links[params.link_id].ap.chandef.chan,
info->extack);
if (err)
- return err;
-
- tb = kzalloc_objs(*tb, NL80211_ATTR_MAX + 1);
- if (!tb)
- return -ENOMEM;
+ goto out;
err = nla_parse_nested(tb, NL80211_ATTR_MAX,
info->attrs[NL80211_ATTR_COLOR_CHANGE_ELEMS],
base-commit: 57aa1718d5953dd532137d43b696c68545c2e0b3
--
2.50.1 (Apple Git-155)
next prev parent reply other threads:[~2026-07-31 4:02 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-08 19:59 [PATCH 0/8] wifi: fix PMSR lifetime and frame validation issues Zhao Li
2026-07-08 19:59 ` [PATCH 1/8] wifi: mac80211_hwsim: clear PMSR request state on abort Zhao Li
2026-07-08 19:59 ` [PATCH 2/8] wifi: mac80211_hwsim: authenticate PMSR report senders Zhao Li
2026-07-08 19:59 ` [PATCH 3/8] wifi: iwlwifi: mld: abort active PMSR requests Zhao Li
2026-07-08 19:59 ` [PATCH 4/8] wifi: cfg80211: guard optional PMSR nominal time Zhao Li
2026-07-08 19:59 ` [PATCH 5/8] wifi: mac80211: validate probe response countdown offsets Zhao Li
2026-07-08 19:59 ` [PATCH 6/8] wifi: mac80211: validate S1G TWT params before driver setup Zhao Li
2026-07-08 19:59 ` [PATCH 7/8] wifi: mwifiex: validate action frame fixed fields Zhao Li
2026-07-08 19:59 ` [PATCH 8/8] wifi: nl80211: clean up color-change beacon data on errors Zhao Li
2026-07-22 14:31 ` Johannes Berg
2026-07-31 4:02 ` Zhao Li [this message]
2026-07-21 16:00 ` [PATCH 0/8] wifi: fix PMSR lifetime and frame validation issues Johannes Berg
2026-07-22 14:37 ` Johannes Berg
2026-07-23 0:25 ` Lachlan Hodges
2026-07-23 8:06 ` Johannes Berg
2026-07-23 1:09 ` Enderaoe Lyther
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260731120244.82628-1-enderaoelyther@gmail.com \
--to=enderaoelyther@gmail.com \
--cc=johannes@sipsolutions.net \
--cc=john@phrozen.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=quic_alokad@quicinc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox