[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221130091759.682841-1-yangyingliang@huawei.com>
Date: Wed, 30 Nov 2022 17:17:59 +0800
From: Yang Yingliang <yangyingliang@...wei.com>
To: <netdev@...r.kernel.org>
CC: <andrew@...n.ch>, <hkallweit1@...il.com>, <linux@...linux.org.uk>,
<davem@...emloft.net>, <edumazet@...gle.com>, <kuba@...nel.org>,
<pabeni@...hat.com>, <ioana.ciornei@....com>,
<calvin.johnson@....nxp.com>, <grant.likely@....com>,
<zengheng4@...wei.com>
Subject: [PATCH net] net: mdiobus: remove unneccessary fwnode_handle_put() in the error path
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() is called in phy_device_release(),
so the fwnode_handle_put() in the error path can be removed to avoid
double put.
Fixes: cdde1560118f ("net: mdiobus: fix unbalanced node reference count")
Reported-by: Zeng Heng <zengheng4@...wei.com>
Tested-by: Zeng Heng <zengheng4@...wei.com>
Signed-off-by: Yang Yingliang <yangyingliang@...wei.com>
---
drivers/net/mdio/fwnode_mdio.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/net/mdio/fwnode_mdio.c b/drivers/net/mdio/fwnode_mdio.c
index eb344f6d4a7b..e584abda585b 100644
--- a/drivers/net/mdio/fwnode_mdio.c
+++ b/drivers/net/mdio/fwnode_mdio.c
@@ -97,10 +97,8 @@ int fwnode_mdiobus_phy_device_register(struct mii_bus *mdio,
* register it
*/
rc = phy_device_register(phy);
- if (rc) {
- fwnode_handle_put(child);
+ if (rc)
return rc;
- }
dev_dbg(&mdio->dev, "registered phy %p fwnode at address %i\n",
child, addr);
@@ -152,10 +150,8 @@ int fwnode_mdiobus_register_phy(struct mii_bus *bus,
/* All data is now stored in the phy struct, so register it */
rc = phy_device_register(phy);
- if (rc) {
- fwnode_handle_put(phy->mdio.dev.fwnode);
+ if (rc)
goto clean_phy;
- }
} else if (is_of_node(child)) {
rc = fwnode_mdiobus_phy_device_register(bus, phy, child, addr);
if (rc)
--
2.25.1
Powered by blists - more mailing lists