]> git.baikalelectronics.ru Git - kernel.git/commit
net: ethernet: mtk_eth_soc: fix off by one check of ARRAY_SIZE
authorTom Rix <trix@redhat.com>
Sat, 16 Jul 2022 21:46:54 +0000 (17:46 -0400)
committerJakub Kicinski <kuba@kernel.org>
Tue, 19 Jul 2022 03:12:04 +0000 (20:12 -0700)
commit4dd37925b0f19d93326d18b01b5f5174da6b3b20
tree91d266fd05ba2f582643d503cacc304e721c6382
parent1959305c797de41255ce577045ea5658f4bc914b
net: ethernet: mtk_eth_soc: fix off by one check of ARRAY_SIZE

In mtk_wed_tx_ring_setup(.., int idx, ..), idx is used as an index here
  struct mtk_wed_ring *ring = &dev->tx_ring[idx];

The bounds of idx are checked here
  BUG_ON(idx > ARRAY_SIZE(dev->tx_ring));

If idx is the size of the array, it will pass this check and overflow.
So change the check to >= .

Fixes: 92f3c8732ac9 ("net: ethernet: mtk_eth_soc: add support for Wireless Ethernet Dispatch (WED)")
Signed-off-by: Tom Rix <trix@redhat.com>
Link: https://lore.kernel.org/r/20220716214654.1540240-1-trix@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mediatek/mtk_wed.c