Skip to content

Commit 88806ef

Browse files
nbd168Paolo Abeni
authored andcommitted
net: ethernet: mtk_eth_soc: fix memory corruption during fq dma init
The loop responsible for allocating up to MTK_FQ_DMA_LENGTH buffers must only touch as many descriptors, otherwise it ends up corrupting unrelated memory. Fix the loop iteration count accordingly. Fixes: c57e558 ("net: ethernet: mtk_eth_soc: handle dma buffer size soc specific") Signed-off-by: Felix Fietkau <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 4678adf commit 88806ef

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/net/ethernet/mediatek/mtk_eth_soc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ static int mtk_init_fq_dma(struct mtk_eth *eth)
11711171
if (unlikely(dma_mapping_error(eth->dma_dev, dma_addr)))
11721172
return -ENOMEM;
11731173

1174-
for (i = 0; i < cnt; i++) {
1174+
for (i = 0; i < len; i++) {
11751175
struct mtk_tx_dma_v2 *txd;
11761176

11771177
txd = eth->scratch_ring + (j * MTK_FQ_DMA_LENGTH + i) * soc->tx.desc_size;

0 commit comments

Comments
 (0)