net: netsec: fix error handling in netsec_register_mdio()
authorYang Yingliang <yangyingliang@huawei.com>
Wed, 19 Oct 2022 06:41:04 +0000 (14:41 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 3 Nov 2022 14:57:51 +0000 (23:57 +0900)
commit62f0a08e82a6312efd7df7f595c0b11d4ffde610
tree7c2636fd3a2d553727dc1971a2c46ff84a37c761
parent32a3d4660b34ce49ac0162338ebe362098e2f5df
net: netsec: fix error handling in netsec_register_mdio()

[ Upstream commit 94423589689124e8cd145b38a1034be7f25835b2 ]

If phy_device_register() fails, phy_device_free() need be called to
put refcount, so memory of phy device and device name can be freed
in callback function.

If get_phy_device() fails, mdiobus_unregister() need be called,
or it will cause warning in mdiobus_free() and kobject is leaked.

Fixes: 533dd11a12f6 ("net: socionext: Add Synquacer NetSec driver")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20221019064104.3228892-1-yangyingliang@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/socionext/netsec.c