All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>,
	"David S. Miller" <davem@davemloft.net>
Cc: Ioana Ciornei <ioana.ciornei@nxp.com>
Subject: [PATCH net-next 2/2] net: dpaa2-switch: call dpaa2_switch_port_disconnect_mac on probe error path
Date: Thu, 19 Aug 2021 17:40:19 +0300	[thread overview]
Message-ID: <20210819144019.2013052-3-vladimir.oltean@nxp.com> (raw)
In-Reply-To: <20210819144019.2013052-1-vladimir.oltean@nxp.com>

Currently when probing returns an error, the netdev is freed but
phylink_disconnect is not called.

Create a common function between the unbind path and the error path,
call it the opposite of dpaa2_switch_probe_port: dpaa2_switch_remove_port,
and call it from both the unbind and the error path.

Fixes: 84cba72956fd ("dpaa2-switch: integrate the MAC endpoint support")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
Note: the dpaa2_switch_remove_port function is placed so far from
dpaa2_switch_probe_port because I wanted to avoid a trivial conflict
with this patch on "net":
https://patchwork.kernel.org/project/netdevbpf/patch/20210819141755.1931423-1-vladimir.oltean@nxp.com/
which moves dpaa2_switch_ctrl_if_teardown around, and this would appear
in the context of the "net-next" patch.

 .../ethernet/freescale/dpaa2/dpaa2-switch.c   | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
index d27c5b841c84..a1a2dc9e4048 100644
--- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
+++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
@@ -2925,6 +2925,18 @@ static int dpaa2_switch_ctrl_if_setup(struct ethsw_core *ethsw)
 	return err;
 }
 
+static void dpaa2_switch_remove_port(struct ethsw_core *ethsw,
+				     u16 port_idx)
+{
+	struct ethsw_port_priv *port_priv = ethsw->ports[port_idx];
+
+	rtnl_lock();
+	dpaa2_switch_port_disconnect_mac(port_priv);
+	rtnl_unlock();
+	free_netdev(port_priv->netdev);
+	ethsw->ports[port_idx] = NULL;
+}
+
 static int dpaa2_switch_init(struct fsl_mc_device *sw_dev)
 {
 	struct device *dev = &sw_dev->dev;
@@ -3201,10 +3213,7 @@ static int dpaa2_switch_remove(struct fsl_mc_device *sw_dev)
 	for (i = 0; i < ethsw->sw_attr.num_ifs; i++) {
 		port_priv = ethsw->ports[i];
 		unregister_netdev(port_priv->netdev);
-		rtnl_lock();
-		dpaa2_switch_port_disconnect_mac(port_priv);
-		rtnl_unlock();
-		free_netdev(port_priv->netdev);
+		dpaa2_switch_remove_port(ethsw, i);
 	}
 
 	kfree(ethsw->fdbs);
@@ -3394,7 +3403,7 @@ static int dpaa2_switch_probe(struct fsl_mc_device *sw_dev)
 	dpsw_disable(ethsw->mc_io, 0, ethsw->dpsw_handle);
 err_free_netdev:
 	for (i--; i >= 0; i--)
-		free_netdev(ethsw->ports[i]->netdev);
+		dpaa2_switch_remove_port(ethsw, i);
 	kfree(ethsw->filter_blocks);
 err_free_fdbs:
 	kfree(ethsw->fdbs);
-- 
2.25.1


  parent reply	other threads:[~2021-08-19 14:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-19 14:40 [PATCH net-next 0/2] dpaa2-switch phylink fixes Vladimir Oltean
2021-08-19 14:40 ` [PATCH net-next 1/2] net: dpaa2-switch: phylink_disconnect_phy needs rtnl_lock Vladimir Oltean
2021-08-19 15:31   ` Ioana Ciornei
2021-08-19 14:40 ` Vladimir Oltean [this message]
2021-08-19 15:32   ` [PATCH net-next 2/2] net: dpaa2-switch: call dpaa2_switch_port_disconnect_mac on probe error path Ioana Ciornei
2021-08-20 13:40 ` [PATCH net-next 0/2] dpaa2-switch phylink fixes patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210819144019.2013052-3-vladimir.oltean@nxp.com \
    --to=vladimir.oltean@nxp.com \
    --cc=davem@davemloft.net \
    --cc=ioana.ciornei@nxp.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.