net: mdiobus: fix double put fwnode in the error path
authorYang Yingliang <yangyingliang@huawei.com>
Fri, 2 Dec 2022 05:18:33 +0000 (13:18 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Dec 2022 10:37:26 +0000 (11:37 +0100)
commitf88acaed07b1794eee9a88f00bd959d72fcfca44
tree02454a1431c6eab1d360013a0553b1abba425f7e
parentcc62d76928e08f41776a249e0a54e659d8738fed
net: mdiobus: fix double put fwnode in the error path

[ Upstream commit 165df24186ecea95705505627df3dacf5e7ff6bf ]

If phy_device_register() or fwnode_mdiobus_phy_device_register()
fail, phy_device_free() is called, the device refcount is decreased
to 0, then fwnode_handle_put() will be called in phy_device_release(),
but in the error path, fwnode_handle_put() has already been called,
so set fwnode to NULL after fwnode_handle_put() in the error path to
avoid double put.

Fixes: cdde1560118f ("net: mdiobus: fix unbalanced node reference count")
Reported-by: Zeng Heng <zengheng4@huawei.com>
Tested-by: Zeng Heng <zengheng4@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Zeng Heng <zengheng4@huawei.com>
Tested-by: Zeng Heng <zengheng4@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/mdio/fwnode_mdio.c