1 From b3d0d98179d62f9d55635a600679c4fa362baf8d Mon Sep 17 00:00:00 2001
2 From: Yang Yingliang <yangyingliang@huawei.com>
3 Date: Mon, 17 Oct 2022 11:51:54 +0800
4 Subject: [PATCH 1/3] net: ethernet: mtk_eth_soc: fix possible memory leak in
7 If mtk_wed_add_hw() has been called, mtk_wed_exit() needs be called
8 in error path or removing module to free the memory allocated in
11 Fixes: 804775dfc288 ("net: ethernet: mtk_eth_soc: add support for Wireless Ethernet Dispatch (WED)")
12 Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
13 Signed-off-by: David S. Miller <davem@davemloft.net>
15 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 17 ++++++++++++-----
16 1 file changed, 12 insertions(+), 5 deletions(-)
18 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
19 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
20 @@ -4006,19 +4006,23 @@ static int mtk_probe(struct platform_dev
21 eth->irq[i] = platform_get_irq(pdev, i);
22 if (eth->irq[i] < 0) {
23 dev_err(&pdev->dev, "no IRQ%d resource found\n", i);
29 for (i = 0; i < ARRAY_SIZE(eth->clks); i++) {
30 eth->clks[i] = devm_clk_get(eth->dev,
31 mtk_clks_source_name[i]);
32 if (IS_ERR(eth->clks[i])) {
33 - if (PTR_ERR(eth->clks[i]) == -EPROBE_DEFER)
34 - return -EPROBE_DEFER;
35 + if (PTR_ERR(eth->clks[i]) == -EPROBE_DEFER) {
36 + err = -EPROBE_DEFER;
39 if (eth->soc->required_clks & BIT(i)) {
40 dev_err(&pdev->dev, "clock %s not found\n",
41 mtk_clks_source_name[i]);
48 @@ -4029,7 +4033,7 @@ static int mtk_probe(struct platform_dev
50 err = mtk_hw_init(eth);
55 eth->hwlro = MTK_HAS_CAPS(eth->soc->caps, MTK_HWLRO);
57 @@ -4127,6 +4131,8 @@ err_free_dev:
66 @@ -4146,6 +4152,7 @@ static int mtk_remove(struct platform_de
67 phylink_disconnect_phy(mac->phylink);
73 netif_napi_del(ð->tx_napi);