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

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

index 29be2fcafea3bc3907fe5b90a8bdb6e7e3997578..fff2b745587e47336b231c4e7e102102b61443ee 100644 (file)
@@ -813,11 +813,11 @@ void mtk_wed_add_hw(struct device_node *np, struct mtk_eth *eth,
        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);
 
@@ -853,8 +853,14 @@ void mtk_wed_add_hw(struct device_node *np, struct mtk_eth *eth,
 
        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)