mt76: fix wcid allocation issues
authorFelix Fietkau <nbd@nbd.name>
Sat, 23 May 2020 12:40:57 +0000 (14:40 +0200)
committerFelix Fietkau <nbd@nbd.name>
Thu, 28 May 2020 15:57:24 +0000 (17:57 +0200)
commit5e616ad216ef560b2a856c858137c772351eee9f
tree84772c3bb9f269d3912b33baeb621e5c1fe925de
parentec2bb3a570ec5bfafb71113b3617929434de5ff0
mt76: fix wcid allocation issues

mt76 core uses ffs() to find the next free bit. This works well for 32 bit
architectures where BITS_PER_LONG is 32. ffs only checks 32 bit values, so
allocation fails on 64 bit architectures.
Additionally, the wcid mask array was too small in cases where the array
was not a multiple of BITS_PER_LONG.
Fix this by making the wcid mask array u32 instead and use DIV_ROUND_UP
for the size, just in case we ever bump it to a value that's not a multiple
of 32.

Reported-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt76.h
drivers/net/wireless/mediatek/mt76/util.c
drivers/net/wireless/mediatek/mt76/util.h