linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] net: mdio: thunder: Fix a double free issue in the .remove function
@ 2021-05-13  7:44 Christophe JAILLET
  2021-05-13  8:11 ` Russell King - ARM Linux admin
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Christophe JAILLET @ 2021-05-13  7:44 UTC (permalink / raw)
  To: andrew, hkallweit1, linux, davem, kuba, david.daney
  Cc: netdev, linux-kernel, kernel-janitors, Christophe JAILLET

'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 <christophe.jaillet@wanadoo.fr>
---
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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH V2] net: mdio: thunder: Fix a double free issue in the .remove function
  2021-05-13  7:44 [PATCH V2] net: mdio: thunder: Fix a double free issue in the .remove function Christophe JAILLET
@ 2021-05-13  8:11 ` Russell King - ARM Linux admin
  2021-05-13  9:37 ` Russell King - ARM Linux admin
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Russell King - ARM Linux admin @ 2021-05-13  8:11 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: andrew, hkallweit1, davem, kuba, david.daney, netdev,
	linux-kernel, kernel-janitors

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!

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH V2] net: mdio: thunder: Fix a double free issue in the .remove function
  2021-05-13  7:44 [PATCH V2] net: mdio: thunder: Fix a double free issue in the .remove function Christophe JAILLET
  2021-05-13  8:11 ` Russell King - ARM Linux admin
@ 2021-05-13  9:37 ` Russell King - ARM Linux admin
  2021-05-13 12:23 ` Andrew Lunn
  2021-05-13 20:20 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Russell King - ARM Linux admin @ 2021-05-13  9:37 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: andrew, hkallweit1, davem, kuba, david.daney, netdev,
	linux-kernel, kernel-janitors

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 <christophe.jaillet@wanadoo.fr>

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 <rmk+kernel@armlinux.org.uk>

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!

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH V2] net: mdio: thunder: Fix a double free issue in the .remove function
  2021-05-13  7:44 [PATCH V2] net: mdio: thunder: Fix a double free issue in the .remove function Christophe JAILLET
  2021-05-13  8:11 ` Russell King - ARM Linux admin
  2021-05-13  9:37 ` Russell King - ARM Linux admin
@ 2021-05-13 12:23 ` Andrew Lunn
  2021-05-13 20:20 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Andrew Lunn @ 2021-05-13 12:23 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: hkallweit1, linux, davem, kuba, david.daney, netdev,
	linux-kernel, kernel-janitors

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 <christophe.jaillet@wanadoo.fr>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH V2] net: mdio: thunder: Fix a double free issue in the .remove function
  2021-05-13  7:44 [PATCH V2] net: mdio: thunder: Fix a double free issue in the .remove function Christophe JAILLET
                   ` (2 preceding siblings ...)
  2021-05-13 12:23 ` Andrew Lunn
@ 2021-05-13 20:20 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-05-13 20:20 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: andrew, hkallweit1, linux, davem, kuba, david.daney, netdev,
	linux-kernel, kernel-janitors

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 <christophe.jaillet@wanadoo.fr>
> 
> [...]

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



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-05-13 20:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-13  7:44 [PATCH V2] net: mdio: thunder: Fix a double free issue in the .remove function Christophe JAILLET
2021-05-13  8:11 ` Russell King - ARM Linux admin
2021-05-13  9:37 ` Russell King - ARM Linux admin
2021-05-13 12:23 ` Andrew Lunn
2021-05-13 20:20 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).