summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/marvell/mwifiex
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2019-04-04 11:44:23 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-05-31 06:48:16 -0700
commitbc2c8535a6b412eba45bc11ea34521309ba00b35 (patch)
tree7bbf3f4f5c3a03791177b80db6e354c2d1ce8dcd /drivers/net/wireless/marvell/mwifiex
parent043a7a249da15df7459787a721adbaaa5cb893d1 (diff)
mwifiex: prevent an array overflow
[ Upstream commit b4c35c17227fe437ded17ce683a6927845f8c4a4 ] The "rate_index" is only used as an index into the phist_data->rx_rate[] array in the mwifiex_hist_data_set() function. That array has MWIFIEX_MAX_AC_RX_RATES (74) elements and it's used to generate some debugfs information. The "rate_index" variable comes from the network skb->data[] and it is a u8 so it's in the 0-255 range. We need to cap it to prevent an array overflow. Fixes: cbf6e05527a7 ("mwifiex: add rx histogram statistics support") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/net/wireless/marvell/mwifiex')
-rw-r--r--drivers/net/wireless/marvell/mwifiex/cfp.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/net/wireless/marvell/mwifiex/cfp.c b/drivers/net/wireless/marvell/mwifiex/cfp.c
index 1ff22055e54f..9ddaa767ea74 100644
--- a/drivers/net/wireless/marvell/mwifiex/cfp.c
+++ b/drivers/net/wireless/marvell/mwifiex/cfp.c
@@ -533,5 +533,8 @@ u8 mwifiex_adjust_data_rate(struct mwifiex_private *priv,
rate_index = (rx_rate > MWIFIEX_RATE_INDEX_OFDM0) ?
rx_rate - 1 : rx_rate;
+ if (rate_index >= MWIFIEX_MAX_AC_RX_RATES)
+ rate_index = MWIFIEX_MAX_AC_RX_RATES - 1;
+
return rate_index;
}