]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: ethernet: mtk_eth_wed: add missing of_node_put()
authorYang Yingliang <yangyingliang@huawei.com>
Mon, 17 Oct 2022 03:51:56 +0000 (11:51 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 29 Oct 2022 08:08:33 +0000 (10:08 +0200)
[ Upstream commit e0bb4659e235770e6f53b3692e958591f49448f5 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/mediatek/mtk_wed.c

index fff2b745587e47336b231c4e7e102102b61443ee..614147ad6116a7896a1c8fa26a55cf755e2121dc 100644 (file)
@@ -808,7 +808,7 @@ void mtk_wed_add_hw(struct device_node *np, struct mtk_eth *eth,
 
        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);
@@ -861,6 +861,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)
@@ -881,6 +883,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);
        }
 }