Skip to content

Commit 3696c95

Browse files
Tom Rixkuba-moo
authored andcommitted
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: 804775d ("net: ethernet: mtk_eth_soc: add support for Wireless Ethernet Dispatch (WED)") Signed-off-by: Tom Rix <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent b6224a3 commit 3696c95

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/net/ethernet/mediatek/mtk_wed.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ mtk_wed_tx_ring_setup(struct mtk_wed_device *dev, int idx, void __iomem *regs)
651651
* WDMA RX.
652652
*/
653653

654-
BUG_ON(idx > ARRAY_SIZE(dev->tx_ring));
654+
BUG_ON(idx >= ARRAY_SIZE(dev->tx_ring));
655655

656656
if (mtk_wed_ring_alloc(dev, ring, MTK_WED_TX_RING_SIZE))
657657
return -ENOMEM;

0 commit comments

Comments
 (0)