All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: mdio: octeon: Fix some double free issues
@ 2021-05-13  7:24 Christophe JAILLET
  2021-05-13  9:44 ` Russell King - ARM Linux admin
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Christophe JAILLET @ 2021-05-13  7:24 UTC (permalink / raw)
  To: andrew, hkallweit1, linux, davem, kuba, f.fainelli
  Cc: netdev, linux-kernel, kernel-janitors, Christophe JAILLET

'bus->mii_bus' has 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 error handling path of the
probe function and in remove function.

Suggested-By: Andrew Lunn <andrew@lunn.ch>
Fixes: 35d2aeac9810 ("phy: mdio-octeon: Use devm_mdiobus_alloc_size()")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
The 'smi_en.u64 = 0; oct_mdio_writeq()' looks odd to me. Usually the normal
path and the error handling path don't write the same value. Here, both
write 0.
Having '1' somewhere would 'look' more usual. :)
More over I think that 'smi_en.s.en = 1;' in the probe is useless.
I don't know what this code is supposed to do, so I leave it as-is.
But it looks like a left-over from a6d678645210.
---
 drivers/net/mdio/mdio-octeon.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/mdio/mdio-octeon.c b/drivers/net/mdio/mdio-octeon.c
index 8ce99c4888e1..e096e68ac667 100644
--- a/drivers/net/mdio/mdio-octeon.c
+++ b/drivers/net/mdio/mdio-octeon.c
@@ -71,7 +71,6 @@ static int octeon_mdiobus_probe(struct platform_device *pdev)
 
 	return 0;
 fail_register:
-	mdiobus_free(bus->mii_bus);
 	smi_en.u64 = 0;
 	oct_mdio_writeq(smi_en.u64, bus->register_base + SMI_EN);
 	return err;
@@ -85,7 +84,6 @@ static int octeon_mdiobus_remove(struct platform_device *pdev)
 	bus = platform_get_drvdata(pdev);
 
 	mdiobus_unregister(bus->mii_bus);
-	mdiobus_free(bus->mii_bus);
 	smi_en.u64 = 0;
 	oct_mdio_writeq(smi_en.u64, bus->register_base + SMI_EN);
 	return 0;
-- 
2.30.2


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

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-13  7:24 [PATCH] net: mdio: octeon: Fix some double free issues Christophe JAILLET
2021-05-13  9:44 ` Russell King - ARM Linux admin
2021-05-13 12:22 ` Andrew Lunn
2021-05-13 22:50 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.