All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: dsa: felix: perform teardown on error in felix_setup
@ 2021-02-16 11:32 Vladimir Oltean
  2021-02-16 22:10 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Vladimir Oltean @ 2021-02-16 11:32 UTC (permalink / raw)
  To: David S . Miller, Jakub Kicinski, netdev
  Cc: Andrew Lunn, Florian Fainelli, Vivien Didelot, Claudiu Manoil,
	Alexandre Belloni, UNGLinuxDriver

From: Vladimir Oltean <vladimir.oltean@nxp.com>

If the driver fails to probe, it would be nice to not leak memory.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
I've decided to target this patch towards net-next because:
- no user has complained about this being an issue
- in theory there should be a Fixes: 56051948773e ("net: dsa: ocelot:
  add driver for Felix switch family") but the fix already conflicts
  with some patches that are in net-next:
  * f59fd9cab730 ("net: mscc: ocelot: configure watermarks using devlink-sb")
  * c54913c1d4ee ("net: dsa: ocelot: request DSA to fix up lack of address learning on CPU port")
  and it would unnecessarily cause maintainance headaches to resolve the
  conflicts.
  Alternatively I could wait until net-next is merged into net and send
  the bugfix at that point, but the result would be the same: the patch
  would not be backportable basically anywhere.

 drivers/net/dsa/ocelot/felix.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
index 3e72f0a79918..4a300ef41de6 100644
--- a/drivers/net/dsa/ocelot/felix.c
+++ b/drivers/net/dsa/ocelot/felix.c
@@ -1202,7 +1202,7 @@ static int felix_setup(struct dsa_switch *ds)
 
 	err = ocelot_init(ocelot);
 	if (err)
-		return err;
+		goto out_mdiobus_free;
 
 	if (ocelot->ptp) {
 		err = ocelot_init_timestamp(ocelot, felix->info->ptp_caps);
@@ -1227,7 +1227,7 @@ static int felix_setup(struct dsa_switch *ds)
 
 	err = ocelot_devlink_sb_register(ocelot);
 	if (err)
-		return err;
+		goto out_deinit_ports;
 
 	for (port = 0; port < ds->num_ports; port++) {
 		if (!dsa_is_cpu_port(ds, port))
@@ -1243,6 +1243,23 @@ static int felix_setup(struct dsa_switch *ds)
 	ds->assisted_learning_on_cpu_port = true;
 
 	return 0;
+
+out_deinit_ports:
+	for (port = 0; port < ocelot->num_phys_ports; port++) {
+		if (dsa_is_unused_port(ds, port))
+			continue;
+
+		ocelot_deinit_port(ocelot, port);
+	}
+
+	ocelot_deinit_timestamp(ocelot);
+	ocelot_deinit(ocelot);
+
+out_mdiobus_free:
+	if (felix->info->mdio_bus_free)
+		felix->info->mdio_bus_free(ocelot);
+
+	return err;
 }
 
 static void felix_teardown(struct dsa_switch *ds)
-- 
2.25.1


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

* Re: [PATCH net-next] net: dsa: felix: perform teardown on error in felix_setup
  2021-02-16 11:32 [PATCH net-next] net: dsa: felix: perform teardown on error in felix_setup Vladimir Oltean
@ 2021-02-16 22:10 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-02-16 22:10 UTC (permalink / raw)
  To: Vladimir Oltean
  Cc: davem, kuba, netdev, andrew, f.fainelli, vivien.didelot,
	claudiu.manoil, alexandre.belloni, UNGLinuxDriver

Hello:

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

On Tue, 16 Feb 2021 13:32:13 +0200 you wrote:
> From: Vladimir Oltean <vladimir.oltean@nxp.com>
> 
> If the driver fails to probe, it would be nice to not leak memory.
> 
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---
> I've decided to target this patch towards net-next because:
> - no user has complained about this being an issue
> - in theory there should be a Fixes: 56051948773e ("net: dsa: ocelot:
>   add driver for Felix switch family") but the fix already conflicts
>   with some patches that are in net-next:
>   * f59fd9cab730 ("net: mscc: ocelot: configure watermarks using devlink-sb")
>   * c54913c1d4ee ("net: dsa: ocelot: request DSA to fix up lack of address learning on CPU port")
>   and it would unnecessarily cause maintainance headaches to resolve the
>   conflicts.
>   Alternatively I could wait until net-next is merged into net and send
>   the bugfix at that point, but the result would be the same: the patch
>   would not be backportable basically anywhere.
> 
> [...]

Here is the summary with links:
  - [net-next] net: dsa: felix: perform teardown on error in felix_setup
    https://git.kernel.org/netdev/net-next/c/6b73b7c96a91

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] 2+ messages in thread

end of thread, other threads:[~2021-02-16 22:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-16 11:32 [PATCH net-next] net: dsa: felix: perform teardown on error in felix_setup Vladimir Oltean
2021-02-16 22:10 ` 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.