Thread (4 messages) flat view 4 messages, 3 authors, 2015-10-29

Re: [PATCH v2 5/6] net: dsa: add missing calls in dsa_switch_destroy

From: Andrew Lunn <andrew@lunn.ch>
Date: 2015-10-29 14:01:11
Also in: lkml

On Thu, Oct 29, 2015 at 02:23:25PM +0100, Neil Armstrong wrote:
quoted hunk ↗ jump to hunk
Add missing netif_carrier_off and phy_disconnect calls to the
dsa_switch_destroy function to make sure the netdev and phy
ressources are clean before complete removal.

Signed-off-by: Frode Isaksen <redacted>
Signed-off-by: Neil Armstrong <redacted>
---
 net/dsa/dsa.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 597a462..11452e4 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -454,7 +454,9 @@ static void dsa_switch_destroy(struct dsa_switch *ds)
 		if (!ds->ports[port])
 			continue;

+		netif_carrier_off(ds->ports[port]);
 		unregister_netdev(ds->ports[port]);
+		phy_disconnect(p->phy);
 		free_netdev(ds->ports[port]);
 	}
Once you make it actually compile....

I'm not sure this is safe. The loop above this one has just destroyed
some phys, and now you are potentially disconnecting a phy you just
destroyed, causing it to be accessed?

I would suggest you first fix the ordering in dsa_switch_destroy()
and then add the missing netif_carrier_off() and phy_disconnect().

Thanks
	Andrew
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help