Commit f7007414 authored by Liu Jian's avatar Liu Jian Committed by Jakub Kicinski
Browse files

net: ethernet: mtk_eth_soc: fix error handling in mtk_open()



If mtk_start_dma() fails, invoke phylink_disconnect_phy() to perform
cleanup. phylink_disconnect_phy() contains the put_device action. If
phylink_disconnect_phy is not performed, the Kref of netdev will leak.

Fixes: b8fc9f30 ("net: ethernet: mediatek: Add basic PHYLINK support")
Signed-off-by: default avatarLiu Jian <liujian56@huawei.com>
Reviewed-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://lore.kernel.org/r/20221117111356.161547-1-liujian56@huawei.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 2360f9b8
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -2996,8 +2996,10 @@ static int mtk_open(struct net_device *dev)
		int i;

		err = mtk_start_dma(eth);
		if (err)
		if (err) {
			phylink_disconnect_phy(mac->phylink);
			return err;
		}

		for (i = 0; i < ARRAY_SIZE(eth->ppe); i++)
			mtk_ppe_start(eth->ppe[i]);