public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] wifi: nl80211: drop impossible negative band check
@ 2026-02-04  8:18 Sun Jian
  2026-02-04  8:36 ` Johannes Berg
  0 siblings, 1 reply; 9+ messages in thread
From: Sun Jian @ 2026-02-04  8:18 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless, linux-kernel, Sun Jian

band is derived from nla_type() of a nested netlink attribute, which is
a masked u16 value and therefore cannot be negative. Drop the dead
"band < 0" checks and keep the upper bound validation.

No functional change intended.

Signed-off-by: Sun Jian <sun.jian.kdev@gmail.com>
---
 net/wireless/nl80211.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 03efd45c007f..a92b4e24b28b 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -5759,7 +5759,7 @@ static int nl80211_parse_tx_bitrate_mask(struct genl_info *info,
 		enum nl80211_band band = nla_type(tx_rates);
 		int err;
 
-		if (band < 0 || band >= NUM_NL80211_BANDS)
+		if (band >= NUM_NL80211_BANDS)
 			return -EINVAL;
 		sband = rdev->wiphy.bands[band];
 		if (sband == NULL)
@@ -10536,7 +10536,7 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
 				    tmp) {
 			enum nl80211_band band = nla_type(attr);
 
-			if (band < 0 || band >= NUM_NL80211_BANDS) {
+			if (band >= NUM_NL80211_BANDS) {
 				err = -EINVAL;
 				goto out_free;
 			}
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-02-06  2:16 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-04  8:18 [PATCH] wifi: nl80211: drop impossible negative band check Sun Jian
2026-02-04  8:36 ` Johannes Berg
2026-02-04  9:13   ` sun jian
2026-02-04 11:11     ` Johannes Berg
2026-02-04 11:21       ` sun jian
2026-02-04 11:29         ` Johannes Berg
2026-02-04 11:33           ` sun jian
2026-02-04 16:20             ` Jeff Johnson
2026-02-06  2:16               ` sun jian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox