From 35cbadbb14b3c60b737f85940468ad6cfe0f05ad Mon Sep 17 00:00:00 2001
From: Jouni Malinen <j@w1.fi>
Date: Wed, 18 Jun 2014 00:45:48 +0300
Subject: [PATCH] VHT: Remove useless validation code from Operating Mode
 Notification

This was added by commit 8a45811638d3d5c913175c4b8fc17a9bff0178e1
('hostapd: Add Operating Mode Notification support'), but the validation
steps cannot be true either for the channel width (which is a two-bit
subfield that cannot encode more than the list four values) or Rx NSS
(which cannot encode a value larger 7). Furthermore, the VHT_CHANWIDTH_*
defines do not match the definition of the Channel Width subfield
values.

Since this check cannot ever match, it is better to remove it to make
the code easier to understand and to avoid getting complaints about dead
code from static analyzers.

Signed-off-by: Jouni Malinen <j@w1.fi>
---
 src/ap/ieee802_11_vht.c | 14 --------------
 1 file changed, 14 deletions(-)

diff --git a/src/ap/ieee802_11_vht.c b/src/ap/ieee802_11_vht.c
index 221d9c207..437cf5031 100644
--- a/src/ap/ieee802_11_vht.c
+++ b/src/ap/ieee802_11_vht.c
@@ -112,25 +112,11 @@ u16 copy_sta_vht_capab(struct hostapd_data *hapd, struct sta_info *sta,
 u16 set_sta_vht_opmode(struct hostapd_data *hapd, struct sta_info *sta,
 		       const u8 *vht_oper_notif)
 {
-	u8 channel_width;
-
 	if (!vht_oper_notif) {
 		sta->flags &= ~WLAN_STA_VHT_OPMODE_ENABLED;
 		return WLAN_STATUS_SUCCESS;
 	}
 
-	channel_width = *vht_oper_notif & VHT_OPMODE_CHANNEL_WIDTH_MASK;
-
-	if (channel_width != VHT_CHANWIDTH_USE_HT &&
-	    channel_width != VHT_CHANWIDTH_80MHZ &&
-	    channel_width != VHT_CHANWIDTH_160MHZ &&
-	    channel_width != VHT_CHANWIDTH_80P80MHZ &&
-	    ((*vht_oper_notif & VHT_OPMODE_CHANNEL_RxNSS_MASK) >>
-	     VHT_OPMODE_NOTIF_RX_NSS_SHIFT) > VHT_RX_NSS_MAX_STREAMS - 1) {
-		sta->flags &= ~WLAN_STA_VHT_OPMODE_ENABLED;
-		return WLAN_STATUS_UNSPECIFIED_FAILURE;
-	}
-
 	sta->flags |= WLAN_STA_VHT_OPMODE_ENABLED;
 	sta->vht_opmode = *vht_oper_notif;
 	return WLAN_STATUS_SUCCESS;