Re: [PATCH] net: mdiobus: Fix memory leak in __mdiobus_register
From: Pavel Skripkin <hidden>
Date: 2021-09-28 10:47:03
Also in:
lkml
On 9/28/21 13:39, Dan Carpenter wrote:
No, the syzbot link was correct.
Link is correct, but Yanfei's patch does not fix this bug. Syzbot reported leak, that you described below, not the Yanfei one.
quoted hunk ↗ jump to hunk
You gave me that link again but I think you must be complaining about a different bug which involves mdiobus_free(). Your bug is something like this: drivers/staging/netlogic/xlr_net.c 838 err = mdiobus_register(priv->mii_bus); 839 if (err) { 840 mdiobus_free(priv->mii_bus); This error path will leak. 841 pr_err("mdio bus registration failed\n"); 842 return err; 843 } Your patch is more complicated than necessary... Just do:diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index ee8313a4ac71..c380a30a77bc 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c@@ -538,6 +538,7 @@ int __mdiobus_register(struct mii_bus *bus, struct module *owner) bus->dev.groups = NULL; dev_set_name(&bus->dev, "%s", bus->id); + bus->state = MDIOBUS_UNREGISTERED; err = device_register(&bus->dev); if (err) { pr_err("mii_bus %s failed to register\n", bus->id);
yep, it's the same as mine, but I thought, that MDIOBUS_UNREGISTERED is not correct name for this state :) Anyway, thank you for suggestion With regards, Pavel Skripkin