Skip to content

Commit

Permalink
nl80211: validate S1G channel width
Browse files Browse the repository at this point in the history
[ Upstream commit 5d087aa ]

Validate the S1G channel width input by user to ensure it matches
that of the requested channel

Signed-off-by: Kieran Frewen <kieran.frewen@morsemicro.com>
Signed-off-by: Bassem Dawood <bassem@morsemicro.com>
Link: https://lore.kernel.org/r/20220420041321.3788789-2-kieran.frewen@morsemicro.com
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Kieran Frewen authored and gregkh committed May 25, 2022
1 parent a0f5ff2 commit 1cfbf6d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions net/wireless/nl80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -2955,6 +2955,15 @@ int nl80211_parse_chandef(struct cfg80211_registered_device *rdev,
} else if (attrs[NL80211_ATTR_CHANNEL_WIDTH]) {
chandef->width =
nla_get_u32(attrs[NL80211_ATTR_CHANNEL_WIDTH]);
if (chandef->chan->band == NL80211_BAND_S1GHZ) {
/* User input error for channel width doesn't match channel */
if (chandef->width != ieee80211_s1g_channel_width(chandef->chan)) {
NL_SET_ERR_MSG_ATTR(extack,
attrs[NL80211_ATTR_CHANNEL_WIDTH],
"bad channel width");
return -EINVAL;
}
}
if (attrs[NL80211_ATTR_CENTER_FREQ1]) {
chandef->center_freq1 =
nla_get_u32(attrs[NL80211_ATTR_CENTER_FREQ1]);
Expand Down

0 comments on commit 1cfbf6d

Please sign in to comment.