diff options
author | Daniel Golle <daniel@makrotopia.org> | 2022-11-02 12:41:40 +0000 |
---|---|---|
committer | Daniel Golle <daniel@makrotopia.org> | 2022-11-02 15:53:34 +0000 |
commit | 1673b7dca3843698fe47f1df0ee61b88d9431ade (patch) | |
tree | e3f25c1970ab2bbc2087d30770fbc192664545d7 | |
parent | 9721a42a272aab941ded476a4baa4a85031c3f07 (diff) | |
download | upstream-1673b7dca3843698fe47f1df0ee61b88d9431ade.tar.gz upstream-1673b7dca3843698fe47f1df0ee61b88d9431ade.tar.bz2 upstream-1673b7dca3843698fe47f1df0ee61b88d9431ade.zip |
kernel: backport fixes for MediaTek Ethernet driver
Backport patches from net-next which fix possible memory and resource
leaks in the error codepaths of WED initialization.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
-rw-r--r-- | target/linux/generic/backport-5.15/726-v6.0-net-ethernet-mtk_eth_soc-fix-mask-of-RX_DMA_GET_SPOR.patch (renamed from target/linux/generic/backport-5.15/788-v6.0-net-ethernet-mtk_eth_soc-fix-mask-of-RX_DMA_GET_SPOR.patch) | 0 | ||||
-rw-r--r-- | target/linux/generic/backport-5.15/727-v6.1-net-ethernet-mtk_eth_soc-fix-state-in-__mtk_foe_entr.patch (renamed from target/linux/generic/backport-5.15/789-v6.1-net-ethernet-mtk_eth_soc-fix-state-in-__mtk_foe_entr.patch) | 0 | ||||
-rw-r--r-- | target/linux/generic/backport-5.15/728-v6.1-01-net-ethernet-mtk_eth_soc-fix-possible-memory-leak-in.patch | 73 | ||||
-rw-r--r-- | target/linux/generic/backport-5.15/728-v6.1-02-net-ethernet-mtk_eth_wed-add-missing-put_device-in-m.patch | 47 | ||||
-rw-r--r-- | target/linux/generic/backport-5.15/728-v6.1-03-net-ethernet-mtk_eth_wed-add-missing-of_node_put.patch | 43 | ||||
-rw-r--r-- | target/linux/generic/pending-5.15/702-net-ethernet-mtk_eth_soc-enable-threaded-NAPI.patch | 2 |
6 files changed, 164 insertions, 1 deletions
diff --git a/target/linux/generic/backport-5.15/788-v6.0-net-ethernet-mtk_eth_soc-fix-mask-of-RX_DMA_GET_SPOR.patch b/target/linux/generic/backport-5.15/726-v6.0-net-ethernet-mtk_eth_soc-fix-mask-of-RX_DMA_GET_SPOR.patch index 27c719b663..27c719b663 100644 --- a/target/linux/generic/backport-5.15/788-v6.0-net-ethernet-mtk_eth_soc-fix-mask-of-RX_DMA_GET_SPOR.patch +++ b/target/linux/generic/backport-5.15/726-v6.0-net-ethernet-mtk_eth_soc-fix-mask-of-RX_DMA_GET_SPOR.patch diff --git a/target/linux/generic/backport-5.15/789-v6.1-net-ethernet-mtk_eth_soc-fix-state-in-__mtk_foe_entr.patch b/target/linux/generic/backport-5.15/727-v6.1-net-ethernet-mtk_eth_soc-fix-state-in-__mtk_foe_entr.patch index 11465c1c5b..11465c1c5b 100644 --- a/target/linux/generic/backport-5.15/789-v6.1-net-ethernet-mtk_eth_soc-fix-state-in-__mtk_foe_entr.patch +++ b/target/linux/generic/backport-5.15/727-v6.1-net-ethernet-mtk_eth_soc-fix-state-in-__mtk_foe_entr.patch diff --git a/target/linux/generic/backport-5.15/728-v6.1-01-net-ethernet-mtk_eth_soc-fix-possible-memory-leak-in.patch b/target/linux/generic/backport-5.15/728-v6.1-01-net-ethernet-mtk_eth_soc-fix-possible-memory-leak-in.patch new file mode 100644 index 0000000000..c419fc8130 --- /dev/null +++ b/target/linux/generic/backport-5.15/728-v6.1-01-net-ethernet-mtk_eth_soc-fix-possible-memory-leak-in.patch @@ -0,0 +1,73 @@ +From b3d0d98179d62f9d55635a600679c4fa362baf8d Mon Sep 17 00:00:00 2001 +From: Yang Yingliang <yangyingliang@huawei.com> +Date: Mon, 17 Oct 2022 11:51:54 +0800 +Subject: [PATCH 1/3] net: ethernet: mtk_eth_soc: fix possible memory leak in + mtk_probe() + +If mtk_wed_add_hw() has been called, mtk_wed_exit() needs be called +in error path or removing module to free the memory allocated in +mtk_wed_add_hw(). + +Fixes: 804775dfc288 ("net: ethernet: mtk_eth_soc: add support for Wireless Ethernet Dispatch (WED)") +Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> +Signed-off-by: David S. Miller <davem@davemloft.net> +--- + drivers/net/ethernet/mediatek/mtk_eth_soc.c | 17 ++++++++++++----- + 1 file changed, 12 insertions(+), 5 deletions(-) + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -4008,19 +4008,23 @@ static int mtk_probe(struct platform_dev + eth->irq[i] = platform_get_irq(pdev, i); + if (eth->irq[i] < 0) { + dev_err(&pdev->dev, "no IRQ%d resource found\n", i); +- return -ENXIO; ++ err = -ENXIO; ++ goto err_wed_exit; + } + } + for (i = 0; i < ARRAY_SIZE(eth->clks); i++) { + eth->clks[i] = devm_clk_get(eth->dev, + mtk_clks_source_name[i]); + if (IS_ERR(eth->clks[i])) { +- if (PTR_ERR(eth->clks[i]) == -EPROBE_DEFER) +- return -EPROBE_DEFER; ++ if (PTR_ERR(eth->clks[i]) == -EPROBE_DEFER) { ++ err = -EPROBE_DEFER; ++ goto err_wed_exit; ++ } + if (eth->soc->required_clks & BIT(i)) { + dev_err(&pdev->dev, "clock %s not found\n", + mtk_clks_source_name[i]); +- return -EINVAL; ++ err = -EINVAL; ++ goto err_wed_exit; + } + eth->clks[i] = NULL; + } +@@ -4031,7 +4035,7 @@ static int mtk_probe(struct platform_dev + + err = mtk_hw_init(eth); + if (err) +- return err; ++ goto err_wed_exit; + + eth->hwlro = MTK_HAS_CAPS(eth->soc->caps, MTK_HWLRO); + +@@ -4129,6 +4133,8 @@ err_free_dev: + mtk_free_dev(eth); + err_deinit_hw: + mtk_hw_deinit(eth); ++err_wed_exit: ++ mtk_wed_exit(); + + return err; + } +@@ -4148,6 +4154,7 @@ static int mtk_remove(struct platform_de + phylink_disconnect_phy(mac->phylink); + } + ++ mtk_wed_exit(); + mtk_hw_deinit(eth); + + netif_napi_del(ð->tx_napi); diff --git a/target/linux/generic/backport-5.15/728-v6.1-02-net-ethernet-mtk_eth_wed-add-missing-put_device-in-m.patch b/target/linux/generic/backport-5.15/728-v6.1-02-net-ethernet-mtk_eth_wed-add-missing-put_device-in-m.patch new file mode 100644 index 0000000000..ef5374dcc5 --- /dev/null +++ b/target/linux/generic/backport-5.15/728-v6.1-02-net-ethernet-mtk_eth_wed-add-missing-put_device-in-m.patch @@ -0,0 +1,47 @@ +From 9d4f20a476ca57e4c9246eb1fa2a61bea2354720 Mon Sep 17 00:00:00 2001 +From: Yang Yingliang <yangyingliang@huawei.com> +Date: Mon, 17 Oct 2022 11:51:55 +0800 +Subject: [PATCH 2/3] net: ethernet: mtk_eth_wed: add missing put_device() in + mtk_wed_add_hw() + +After calling get_device() in mtk_wed_add_hw(), in error path, put_device() +needs be called. + +Fixes: 804775dfc288 ("net: ethernet: mtk_eth_soc: add support for Wireless Ethernet Dispatch (WED)") +Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> +Signed-off-by: David S. Miller <davem@davemloft.net> +--- + drivers/net/ethernet/mediatek/mtk_wed.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +--- a/drivers/net/ethernet/mediatek/mtk_wed.c ++++ b/drivers/net/ethernet/mediatek/mtk_wed.c +@@ -1084,11 +1084,11 @@ void mtk_wed_add_hw(struct device_node * + get_device(&pdev->dev); + irq = platform_get_irq(pdev, 0); + if (irq < 0) +- return; ++ goto err_put_device; + + regs = syscon_regmap_lookup_by_phandle(np, NULL); + if (IS_ERR(regs)) +- return; ++ goto err_put_device; + + rcu_assign_pointer(mtk_soc_wed_ops, &wed_ops); + +@@ -1131,8 +1131,14 @@ void mtk_wed_add_hw(struct device_node * + + hw_list[index] = hw; + ++ mutex_unlock(&hw_lock); ++ ++ return; ++ + unlock: + mutex_unlock(&hw_lock); ++err_put_device: ++ put_device(&pdev->dev); + } + + void mtk_wed_exit(void) diff --git a/target/linux/generic/backport-5.15/728-v6.1-03-net-ethernet-mtk_eth_wed-add-missing-of_node_put.patch b/target/linux/generic/backport-5.15/728-v6.1-03-net-ethernet-mtk_eth_wed-add-missing-of_node_put.patch new file mode 100644 index 0000000000..0a452d4a7d --- /dev/null +++ b/target/linux/generic/backport-5.15/728-v6.1-03-net-ethernet-mtk_eth_wed-add-missing-of_node_put.patch @@ -0,0 +1,43 @@ +From e0bb4659e235770e6f53b3692e958591f49448f5 Mon Sep 17 00:00:00 2001 +From: Yang Yingliang <yangyingliang@huawei.com> +Date: Mon, 17 Oct 2022 11:51:56 +0800 +Subject: [PATCH 3/3] net: ethernet: mtk_eth_wed: add missing of_node_put() + +The device_node pointer returned by of_parse_phandle() with refcount +incremented, when finish using it, the refcount need be decreased. + +Fixes: 804775dfc288 ("net: ethernet: mtk_eth_soc: add support for Wireless Ethernet Dispatch (WED)") +Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> +Signed-off-by: David S. Miller <davem@davemloft.net> +--- + drivers/net/ethernet/mediatek/mtk_wed.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +--- a/drivers/net/ethernet/mediatek/mtk_wed.c ++++ b/drivers/net/ethernet/mediatek/mtk_wed.c +@@ -1079,7 +1079,7 @@ void mtk_wed_add_hw(struct device_node * + + pdev = of_find_device_by_node(np); + if (!pdev) +- return; ++ goto err_of_node_put; + + get_device(&pdev->dev); + irq = platform_get_irq(pdev, 0); +@@ -1139,6 +1139,8 @@ unlock: + mutex_unlock(&hw_lock); + err_put_device: + put_device(&pdev->dev); ++err_of_node_put: ++ of_node_put(np); + } + + void mtk_wed_exit(void) +@@ -1159,6 +1161,7 @@ void mtk_wed_exit(void) + hw_list[i] = NULL; + debugfs_remove(hw->debugfs_dir); + put_device(hw->dev); ++ of_node_put(hw->node); + kfree(hw); + } + } diff --git a/target/linux/generic/pending-5.15/702-net-ethernet-mtk_eth_soc-enable-threaded-NAPI.patch b/target/linux/generic/pending-5.15/702-net-ethernet-mtk_eth_soc-enable-threaded-NAPI.patch index 670c2b04a8..3e1486962c 100644 --- a/target/linux/generic/pending-5.15/702-net-ethernet-mtk_eth_soc-enable-threaded-NAPI.patch +++ b/target/linux/generic/pending-5.15/702-net-ethernet-mtk_eth_soc-enable-threaded-NAPI.patch @@ -30,7 +30,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name> } return IRQ_HANDLED; -@@ -4114,6 +4114,8 @@ static int mtk_probe(struct platform_dev +@@ -4118,6 +4118,8 @@ static int mtk_probe(struct platform_dev * for NAPI to work */ init_dummy_netdev(ð->dummy_dev); |