git: 30e8252353d9 - main - net80211: HT: check for feature support in ht_recv_action_ht_txchwidth()

From: Bjoern A. Zeeb <bz_at_FreeBSD.org>
Date: Sun, 08 Dec 2024 21:03:05 UTC
The branch main has been updated by bz:

URL: https://cgit.FreeBSD.org/src/commit/?id=30e8252353d95cc77f787ef784942a551d3e0567

commit 30e8252353d95cc77f787ef784942a551d3e0567
Author:     Bjoern A. Zeeb <bz@FreeBSD.org>
AuthorDate: 2024-12-01 20:16:19 +0000
Commit:     Bjoern A. Zeeb <bz@FreeBSD.org>
CommitDate: 2024-12-08 21:01:40 +0000

    net80211: HT: check for feature support in ht_recv_action_ht_txchwidth()
    
    ht_recv_action_ht_txchwidth() can blindly change the channel width to
    40 Mhz whether or not that is supported.  If 20/40 is not supported
    there is nothing to do as the channel width cannot change in that case.
    
    While here mark unused arguments with __unused.
    
    Sponosred by:   The FreeBSD Foundation
    MFC adter:      3 days
    Reviewed by:    adrian
    Differential Revision: https://reviews.freebsd.org/D47857
---
 sys/net80211/ieee80211_ht.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/sys/net80211/ieee80211_ht.c b/sys/net80211/ieee80211_ht.c
index 293b5be20d32..e2506c1e0ce0 100644
--- a/sys/net80211/ieee80211_ht.c
+++ b/sys/net80211/ieee80211_ht.c
@@ -2595,11 +2595,15 @@ ht_recv_action_ba_delba(struct ieee80211_node *ni,
 
 static int
 ht_recv_action_ht_txchwidth(struct ieee80211_node *ni,
-	const struct ieee80211_frame *wh,
-	const uint8_t *frm, const uint8_t *efrm)
+	const struct ieee80211_frame *wh __unused,
+	const uint8_t *frm, const uint8_t *efrm __unused)
 {
 	int chw;
 
+	/* If 20/40 is not supported the chw cannot change. */
+	if ((ni->ni_htcap & IEEE80211_HTCAP_CHWIDTH40) == 0)
+		return (0);
+
 	chw = (frm[2] == IEEE80211_A_HT_TXCHWIDTH_2040) ?
 	    IEEE80211_STA_RX_BW_40 : IEEE80211_STA_RX_BW_20;