From 53be64f7d9abfb4af8cdafb34940e6830151359c Mon Sep 17 00:00:00 2001 From: Shiva Sankar Gajula Date: Fri, 4 Feb 2022 23:13:30 +0530 Subject: [PATCH] HE: Fix calculation of the PPE Threshold field length The previously used calculation was not correct for the cases where the extra padding field was needed. Fix this by properly calculating the number of full octets in the field. Fixes: 0497e4148197 ("HE: Fix HE Capabilities element size") Signed-off-by: Shiva Sankar Gajula --- src/ap/ieee802_11_he.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ap/ieee802_11_he.c b/src/ap/ieee802_11_he.c index 6cd6c90dc..6e368ff33 100644 --- a/src/ap/ieee802_11_he.c +++ b/src/ap/ieee802_11_he.c @@ -29,17 +29,19 @@ static u8 ieee80211_he_ppet_size(u8 ppe_thres_hdr, const u8 *phy_cap_info) ru = (ppe_thres_hdr >> HE_PPE_THRES_RU_INDEX_BITMASK_SHIFT) & HE_PPE_THRES_RU_INDEX_BITMASK_MASK; + /* Count the number of 1 bits in RU Index Bitmask */ while (ru) { if (ru & 0x1) sz++; ru >>= 1; } + /* fixed header of 3 (NSTS) + 4 (RU Index Bitmask) = 7 bits */ + /* 6 * (NSTS + 1) bits for bit 1 in RU Index Bitmask */ sz *= 1 + (ppe_thres_hdr & HE_PPE_THRES_NSS_MASK); sz = (sz * 6) + 7; - if (sz % 8) - sz += 8; - sz /= 8; + /* PPE Pad to count the number of needed full octets */ + sz = (sz + 7) / 8; return sz; }