]> git.ipfire.org Git - thirdparty/openwrt.git/blob
38b305f0fef7792a3554860e9d6d65e3d1c7f52c
[thirdparty/openwrt.git] /
1 From 88806efc034a9830f483963326b99930ad519af1 Mon Sep 17 00:00:00 2001
2 From: Felix Fietkau <nbd@nbd.name>
3 Date: Tue, 15 Oct 2024 10:17:55 +0200
4 Subject: [PATCH] net: ethernet: mtk_eth_soc: fix memory corruption during fq
5 dma init
6
7 The loop responsible for allocating up to MTK_FQ_DMA_LENGTH buffers must
8 only touch as many descriptors, otherwise it ends up corrupting unrelated
9 memory. Fix the loop iteration count accordingly.
10
11 Fixes: c57e55819443 ("net: ethernet: mtk_eth_soc: handle dma buffer size soc specific")
12 Signed-off-by: Felix Fietkau <nbd@nbd.name>
13 Reviewed-by: Simon Horman <horms@kernel.org>
14 Link: https://patch.msgid.link/20241015081755.31060-1-nbd@nbd.name
15 Signed-off-by: Paolo Abeni <pabeni@redhat.com>
16 ---
17 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 2 +-
18 1 file changed, 1 insertion(+), 1 deletion(-)
19
20 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
21 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
22 @@ -1181,7 +1181,7 @@ static int mtk_init_fq_dma(struct mtk_et
23 if (unlikely(dma_mapping_error(eth->dma_dev, dma_addr)))
24 return -ENOMEM;
25
26 - for (i = 0; i < cnt; i++) {
27 + for (i = 0; i < len; i++) {
28 struct mtk_tx_dma_v2 *txd;
29
30 txd = eth->scratch_ring + (j * MTK_FQ_DMA_LENGTH + i) * soc->tx.desc_size;