[openwrt/openwrt] kernel: fix mtk_eth_soc memory corruption issue on fq dma init

LEDE Commits lede-commits at lists.infradead.org
Tue Oct 15 01:22:21 PDT 2024


nbd pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/506d0c421b1b0df6adb75506b3b20622b264b15f

commit 506d0c421b1b0df6adb75506b3b20622b264b15f
Author: Felix Fietkau <nbd at nbd.name>
AuthorDate: Tue Oct 15 10:21:47 2024 +0200

    kernel: fix mtk_eth_soc memory corruption issue on fq dma init
    
    Signed-off-by: Felix Fietkau <nbd at nbd.name>
---
 ...t-mtk_eth_soc-fix-memory-corruption-durin.patch | 24 ++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/target/linux/generic/pending-6.6/735-net-ethernet-mtk_eth_soc-fix-memory-corruption-durin.patch b/target/linux/generic/pending-6.6/735-net-ethernet-mtk_eth_soc-fix-memory-corruption-durin.patch
new file mode 100644
index 0000000000..5d7902b1cf
--- /dev/null
+++ b/target/linux/generic/pending-6.6/735-net-ethernet-mtk_eth_soc-fix-memory-corruption-durin.patch
@@ -0,0 +1,24 @@
+From: Felix Fietkau <nbd at nbd.name>
+Date: Tue, 15 Oct 2024 10:13:55 +0200
+Subject: [PATCH] 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")
+Signed-off-by: Felix Fietkau <nbd at nbd.name>
+---
+
+--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+@@ -1172,7 +1172,7 @@ static int mtk_init_fq_dma(struct mtk_et
+ 		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;




More information about the lede-commits mailing list