All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 net-next] net: dsa: unlock the rtnl_mutex when dsa_master_setup() fails
@ 2022-03-03 14:08 Vladimir Oltean
  2022-03-05  4:56 ` Jakub Kicinski
  0 siblings, 1 reply; 4+ messages in thread
From: Vladimir Oltean @ 2022-03-03 14:08 UTC (permalink / raw)
  To: netdev
  Cc: Jakub Kicinski, David S. Miller, Florian Fainelli, Andrew Lunn,
	Vivien Didelot, Vladimir Oltean

After the blamed commit, dsa_tree_setup_master() may exit without
calling rtnl_unlock(), fix that.

Fixes: c146f9bc195a ("net: dsa: hold rtnl_mutex when calling dsa_master_{setup,teardown}")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
v1->v2: actually propagate the error code instead of always returning 0

 net/dsa/dsa2.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index 030d5f26715a..d26430e33096 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -1072,7 +1072,7 @@ static int dsa_tree_setup_switches(struct dsa_switch_tree *dst)
 static int dsa_tree_setup_master(struct dsa_switch_tree *dst)
 {
 	struct dsa_port *dp;
-	int err;
+	int err = 0;
 
 	rtnl_lock();
 
@@ -1084,7 +1084,7 @@ static int dsa_tree_setup_master(struct dsa_switch_tree *dst)
 
 			err = dsa_master_setup(master, dp);
 			if (err)
-				return err;
+				break;
 
 			/* Replay master state event */
 			dsa_tree_master_admin_state_change(dst, master, admin_up);
@@ -1095,7 +1095,7 @@ static int dsa_tree_setup_master(struct dsa_switch_tree *dst)
 
 	rtnl_unlock();
 
-	return 0;
+	return err;
 }
 
 static void dsa_tree_teardown_master(struct dsa_switch_tree *dst)
-- 
2.25.1


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

end of thread, other threads:[~2022-03-07 21:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-03 14:08 [PATCH v2 net-next] net: dsa: unlock the rtnl_mutex when dsa_master_setup() fails Vladimir Oltean
2022-03-05  4:56 ` Jakub Kicinski
2022-03-05 12:32   ` Vladimir Oltean
2022-03-07 21:44     ` Jakub Kicinski

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.