Skip to content

Commit

Permalink
net: ethernet: mtk_eth_soc: fix memory corruption during fq dma init
Browse files Browse the repository at this point in the history
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 <nbd@nbd.name>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20241015081755.31060-1-nbd@nbd.name
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
  • Loading branch information
nbd168 authored and frank-w committed Nov 25, 2024
1 parent 7a99830 commit 2a45d35
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/ethernet/mediatek/mtk_eth_soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1311,7 +1311,7 @@ static int mtk_init_fq_dma(struct mtk_eth *eth)
if (unlikely(dma_mapping_error(eth->dma_dev, dma_addr)))
return -ENOMEM;

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

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

0 comments on commit 2a45d35

Please sign in to comment.