Commit 88806efc authored by Felix Fietkau's avatar Felix Fietkau Committed by Paolo Abeni

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: c57e5581 ("net: ethernet: mtk_eth_soc: handle dma buffer size soc specific")
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20241015081755.31060-1-nbd@nbd.nameSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 4678adf9
...@@ -1171,7 +1171,7 @@ static int mtk_init_fq_dma(struct mtk_eth *eth) ...@@ -1171,7 +1171,7 @@ static int mtk_init_fq_dma(struct mtk_eth *eth)
if (unlikely(dma_mapping_error(eth->dma_dev, dma_addr))) if (unlikely(dma_mapping_error(eth->dma_dev, dma_addr)))
return -ENOMEM; return -ENOMEM;
for (i = 0; i < cnt; i++) { for (i = 0; i < len; i++) {
struct mtk_tx_dma_v2 *txd; struct mtk_tx_dma_v2 *txd;
txd = eth->scratch_ring + (j * MTK_FQ_DMA_LENGTH + i) * soc->tx.desc_size; txd = eth->scratch_ring + (j * MTK_FQ_DMA_LENGTH + i) * soc->tx.desc_size;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment