All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net: dsa: Check return value of phy_connect_direct()
@ 2017-01-21  0:05 Florian Fainelli
  2017-01-23 20:43 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Florian Fainelli @ 2017-01-21  0:05 UTC (permalink / raw)
  To: netdev; +Cc: davem, vivien.didelot, andrew, Florian Fainelli

We need to check the return value of phy_connect_direct() in
dsa_slave_phy_connect() otherwise we may be continuing the
initialization of a slave network device with a PHY that already
attached somewhere else and which will soon be in error because the PHY
device is in error.

The conditions for such an error to occur are that we have a port of our
switch that is not disabled, and has the same port number as a PHY
address (say both 5) that can be probed using the DSA slave MII bus. We
end-up having this slave network device find a PHY at the same address
as our port number, and we try to attach to it.

A slave network (e.g: port 0) has already attached to our PHY device,
and we try to re-attach it with a different network device, but since we
ignore the error we would end-up initializating incorrect device
references by the time the slave network interface is opened.

The code has been (re)organized several times, making it hard to provide
an exact Fixes tag, this is a bugfix nonetheless.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 net/dsa/slave.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 68c9eea00518..ba1b6b9630d2 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -1105,10 +1105,8 @@ static int dsa_slave_phy_connect(struct dsa_slave_priv *p,
 	/* Use already configured phy mode */
 	if (p->phy_interface == PHY_INTERFACE_MODE_NA)
 		p->phy_interface = p->phy->interface;
-	phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link,
-			   p->phy_interface);
-
-	return 0;
+	return phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link,
+				  p->phy_interface);
 }
 
 static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
-- 
2.11.0

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

* Re: [PATCH net] net: dsa: Check return value of phy_connect_direct()
  2017-01-21  0:05 [PATCH net] net: dsa: Check return value of phy_connect_direct() Florian Fainelli
@ 2017-01-23 20:43 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-01-23 20:43 UTC (permalink / raw)
  To: f.fainelli; +Cc: netdev, vivien.didelot, andrew

From: Florian Fainelli <f.fainelli@gmail.com>
Date: Fri, 20 Jan 2017 16:05:05 -0800

> We need to check the return value of phy_connect_direct() in
> dsa_slave_phy_connect() otherwise we may be continuing the
> initialization of a slave network device with a PHY that already
> attached somewhere else and which will soon be in error because the PHY
> device is in error.
> 
> The conditions for such an error to occur are that we have a port of our
> switch that is not disabled, and has the same port number as a PHY
> address (say both 5) that can be probed using the DSA slave MII bus. We
> end-up having this slave network device find a PHY at the same address
> as our port number, and we try to attach to it.
> 
> A slave network (e.g: port 0) has already attached to our PHY device,
> and we try to re-attach it with a different network device, but since we
> ignore the error we would end-up initializating incorrect device
> references by the time the slave network interface is opened.
> 
> The code has been (re)organized several times, making it hard to provide
> an exact Fixes tag, this is a bugfix nonetheless.
> 
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>

Applied, thanks Florian.

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

end of thread, other threads:[~2017-01-23 20:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-21  0:05 [PATCH net] net: dsa: Check return value of phy_connect_direct() Florian Fainelli
2017-01-23 20:43 ` David Miller

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.