[PATCH V2] net: mdio: thunder: Fix a double free issue in the .remove function

Subsystems: ethernet phy library, networking drivers, the rest

STALE1918d

5 messages, 4 authors, 2021-05-13 · open the first message on its own page

[PATCH V2] net: mdio: thunder: Fix a double free issue in the .remove function

From: Christophe JAILLET <hidden>
Date: 2021-05-13 07:46:44

'bus->mii_bus' have been allocated with 'devm_mdiobus_alloc_size()' in the
probe function. So it must not be freed explicitly or there will be a
double free.

Remove the incorrect 'mdiobus_free' in the remove function.

Fixes: 379d7ac7ca31 ("phy: mdio-thunder: Add driver for Cavium Thunder SoC MDIO buses.")
Signed-off-by: Christophe JAILLET <redacted>
---
v2: indicate in the subject which mdio bus driver has a double free
---
 drivers/net/mdio/mdio-thunder.c | 1 -
 1 file changed, 1 deletion(-)
diff --git a/drivers/net/mdio/mdio-thunder.c b/drivers/net/mdio/mdio-thunder.c
index cb1761693b69..822d2cdd2f35 100644
--- a/drivers/net/mdio/mdio-thunder.c
+++ b/drivers/net/mdio/mdio-thunder.c
@@ -126,7 +126,6 @@ static void thunder_mdiobus_pci_remove(struct pci_dev *pdev)
 			continue;
 
 		mdiobus_unregister(bus->mii_bus);
-		mdiobus_free(bus->mii_bus);
 		oct_mdio_writeq(0, bus->register_base + SMI_EN);
 	}
 	pci_release_regions(pdev);
-- 
2.30.2

Re: [PATCH V2] net: mdio: thunder: Fix a double free issue in the .remove function

From: Russell King - ARM Linux admin <linux@armlinux.org.uk>
Date: 2021-05-13 08:11:49

On Thu, May 13, 2021 at 09:44:49AM +0200, Christophe JAILLET wrote:
'bus->mii_bus' have been allocated with 'devm_mdiobus_alloc_size()' in the
probe function. So it must not be freed explicitly or there will be a
double free.

Remove the incorrect 'mdiobus_free' in the remove function.
This still leaves the unregister of an allocated-but-unregistered bus,
which you disagreed with - but I hope as I've pointed out the exact
code path in your v1 patch, you'll now realise is a real possibility.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

Re: [PATCH V2] net: mdio: thunder: Fix a double free issue in the .remove function

From: Russell King - ARM Linux admin <linux@armlinux.org.uk>
Date: 2021-05-13 09:38:13

On Thu, May 13, 2021 at 09:44:49AM +0200, Christophe JAILLET wrote:
'bus->mii_bus' have been allocated with 'devm_mdiobus_alloc_size()' in the
probe function. So it must not be freed explicitly or there will be a
double free.

Remove the incorrect 'mdiobus_free' in the remove function.

Fixes: 379d7ac7ca31 ("phy: mdio-thunder: Add driver for Cavium Thunder SoC MDIO buses.")
Signed-off-by: Christophe JAILLET <redacted>
Also note that I did review your patch, and give you a reviewed-by for
it, which I think should have been carried over to v2 since Andrew's
comment was only concerning the formatting of the subject line. The
patch content is entirely fine. So, I'll give it again, so patchwork
gets the right information:

Reviewed-by: Russell King <redacted>

My comments about the unregistration are a separate bug that should be
addressed in a separate follow-on patch. Thanks.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

Re: [PATCH V2] net: mdio: thunder: Fix a double free issue in the .remove function

From: Andrew Lunn <andrew@lunn.ch>
Date: 2021-05-13 12:24:00

On Thu, May 13, 2021 at 09:44:49AM +0200, Christophe JAILLET wrote:
'bus->mii_bus' have been allocated with 'devm_mdiobus_alloc_size()' in the
probe function. So it must not be freed explicitly or there will be a
double free.

Remove the incorrect 'mdiobus_free' in the remove function.

Fixes: 379d7ac7ca31 ("phy: mdio-thunder: Add driver for Cavium Thunder SoC MDIO buses.")
Signed-off-by: Christophe JAILLET <redacted>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

Re: [PATCH V2] net: mdio: thunder: Fix a double free issue in the .remove function

From: patchwork-bot+netdevbpf@kernel.org
Date: 2021-05-13 20:20:17

Hello:

This patch was applied to netdev/net.git (refs/heads/master):

On Thu, 13 May 2021 09:44:49 +0200 you wrote:
'bus->mii_bus' have been allocated with 'devm_mdiobus_alloc_size()' in the
probe function. So it must not be freed explicitly or there will be a
double free.

Remove the incorrect 'mdiobus_free' in the remove function.

Fixes: 379d7ac7ca31 ("phy: mdio-thunder: Add driver for Cavium Thunder SoC MDIO buses.")
Signed-off-by: Christophe JAILLET <redacted>

[...]
Here is the summary with links:
  - [V2] net: mdio: thunder: Fix a double free issue in the .remove function
    https://git.kernel.org/netdev/net/c/a93a0a15876d

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help