Skip to contentSkip to conversation

net: ethernet: mtk_eth_soc: fix memory corruption during fq dma init

PATCH Applied Felix Fietkau 3 participants 3 messages Oct 15, 2024 – Oct 17, 2024

Subsystems (4)
lore
Share & tools
lore

Felix Fietkau

author maintainer
#0 lore raw

PATCH 1/1 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 c57e55819443 ("net: ethernet: mtk_eth_soc: handle dma buffer size soc specific")
---
 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mediatek/mtk_eth_soc.c +1 -1
index 16ca427cf4c3..ed7313c10a05 100644
@@ -1171,7 +1171,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;
Signature · 1 line
2.47.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Felix Fietkau

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 c57e55819443 ("net: ethernet: mtk_eth_soc: handle dma buffer size soc specific")
#2 lore raw
In reply to Felix Fietkau
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:

Quoted 8 lines · On Tue, 15 Oct 2024 10:17:55 +0200 you wrote:

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 c57e55819443 ("net: ethernet: mtk_eth_soc: handle dma buffer size soc specific")

[...]

Here is the summary with links:
- [net] net: ethernet: mtk_eth_soc: fix memory corruption during fq dma init

    https://git.kernel.org/netdev/net/c/88806efc034a

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html