From: Johannes Berg That's a nonsensical configuration, and we get errors reported further down in mac80211 for it; hostapd has code that only adds the nested element if it'll not be an empty list. Remove an unnecessary NULL check while at it. Fixes: dbbb27e183b1 ("cfg80211: support RNR for EMA AP") Assisted-by: LLM Signed-off-by: Johannes Berg --- net/wireless/nl80211.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 7ee69ec10b0f..9c2d5c89598b 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c @@ -6582,6 +6582,9 @@ nl80211_parse_mbssid_elems(struct wiphy *wiphy, struct nlattr *attrs, num_elems++; } + if (!num_elems) + return ERR_PTR(-EINVAL); + elems = kzalloc_flex(*elems, elem, num_elems); if (!elems) return ERR_PTR(-ENOMEM); @@ -6617,6 +6620,9 @@ nl80211_parse_rnr_elems(struct wiphy *wiphy, struct nlattr *attrs, num_elems++; } + if (!num_elems) + return ERR_PTR(-EINVAL); + elems = kzalloc_flex(*elems, elem, num_elems); if (!elems) return ERR_PTR(-ENOMEM); @@ -6860,7 +6866,8 @@ static int nl80211_parse_beacon(struct cfg80211_registered_device *rdev, if (IS_ERR(rnr)) return PTR_ERR(rnr); - if (rnr && rnr->cnt < bcn->mbssid_ies->cnt) { + /* RNR elements are only used with MBSSID elements */ + if (rnr->cnt < bcn->mbssid_ies->cnt) { kfree(rnr); return -EINVAL; } -- 2.55.0