wifi: mt76: fix coverity overrun-call in mt76_get_txpower()
authorDeren Wu <deren.wu@mediatek.com>
Sun, 27 Nov 2022 02:35:37 +0000 (10:35 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 31 Dec 2022 12:32:21 +0000 (13:32 +0100)
commiteb91025565658702c0ebb4ab26aca62d3239ae20
tree6e0d06ae9623c9c484c5e7727ee728ec852334ea
parentf11c5a1926c9430b90e19fe5d8dcc0e1ee71a0ca
wifi: mt76: fix coverity overrun-call in mt76_get_txpower()

[ Upstream commit 03dd0d49de7db680a856fa566963bb8421f46368 ]

Make sure the nss is valid for nss_delta array. Return zero
if the index is invalid.

Coverity message:
Event overrun-call: Overrunning callee's array of size 4 by passing
argument "n_chains" (which evaluates to 15) in call to
"mt76_tx_power_nss_delta".
int delta = mt76_tx_power_nss_delta(n_chains);

Fixes: 07cda406308b ("mt76: fix rounding issues on converting per-chain and combined txpower")
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wireless/mediatek/mt76/mt76.h