* [net-next] net: dsa: Avoid null pointer when failing to connect to PHY
@ 2019-03-23 23:24 Vladimir Oltean
2019-03-24 1:17 ` Florian Fainelli
2019-03-26 18:27 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Vladimir Oltean @ 2019-03-23 23:24 UTC (permalink / raw)
To: davem, f.fainelli, netdev; +Cc: andrew, vivien.didelot, Vladimir Oltean
When phylink_of_phy_connect fails, dsa_slave_phy_setup tries to save the
day by connecting to an alternative PHY, none other than a PHY on the
switch's internal MDIO bus, at an address equal to the port's index.
However this does not take into consideration the scenario when the
switch that failed to probe an external PHY does not have an internal
MDIO bus at all.
Fixes: aab9c4067d23 ("net: dsa: Plug in PHYLINK support")
Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
---
net/dsa/slave.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 093eef6f2599..6a8418dfa64f 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -1283,9 +1283,9 @@ static int dsa_slave_phy_setup(struct net_device *slave_dev)
phy_flags = ds->ops->get_phy_flags(ds, dp->index);
ret = phylink_of_phy_connect(dp->pl, port_dn, phy_flags);
- if (ret == -ENODEV) {
- /* We could not connect to a designated PHY or SFP, so use the
- * switch internal MDIO bus instead
+ if (ret == -ENODEV && ds->slave_mii_bus) {
+ /* We could not connect to a designated PHY or SFP, so try to
+ * use the switch internal MDIO bus instead
*/
ret = dsa_slave_phy_connect(slave_dev, dp->index);
if (ret) {
@@ -1297,7 +1297,7 @@ static int dsa_slave_phy_setup(struct net_device *slave_dev)
}
}
- return 0;
+ return ret;
}
static struct lock_class_key dsa_slave_netdev_xmit_lock_key;
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [net-next] net: dsa: Avoid null pointer when failing to connect to PHY
2019-03-23 23:24 [net-next] net: dsa: Avoid null pointer when failing to connect to PHY Vladimir Oltean
@ 2019-03-24 1:17 ` Florian Fainelli
2019-03-26 18:27 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Florian Fainelli @ 2019-03-24 1:17 UTC (permalink / raw)
To: Vladimir Oltean, davem, netdev; +Cc: andrew, vivien.didelot
On 3/23/2019 4:24 PM, Vladimir Oltean wrote:
> When phylink_of_phy_connect fails, dsa_slave_phy_setup tries to save the
> day by connecting to an alternative PHY, none other than a PHY on the
> switch's internal MDIO bus, at an address equal to the port's index.
>
> However this does not take into consideration the scenario when the
> switch that failed to probe an external PHY does not have an internal
> MDIO bus at all.
>
> Fixes: aab9c4067d23 ("net: dsa: Plug in PHYLINK support")
> Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
This goes back to before that commit, pretty much since
0d8bcdd383b8865e752a7e8edb4712c2e3902052 ("net: dsa: allow for more
complex PHY setups").
--
Florian
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [net-next] net: dsa: Avoid null pointer when failing to connect to PHY
2019-03-23 23:24 [net-next] net: dsa: Avoid null pointer when failing to connect to PHY Vladimir Oltean
2019-03-24 1:17 ` Florian Fainelli
@ 2019-03-26 18:27 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-03-26 18:27 UTC (permalink / raw)
To: olteanv; +Cc: f.fainelli, netdev, andrew, vivien.didelot
From: Vladimir Oltean <olteanv@gmail.com>
Date: Sun, 24 Mar 2019 01:24:07 +0200
> When phylink_of_phy_connect fails, dsa_slave_phy_setup tries to save the
> day by connecting to an alternative PHY, none other than a PHY on the
> switch's internal MDIO bus, at an address equal to the port's index.
>
> However this does not take into consideration the scenario when the
> switch that failed to probe an external PHY does not have an internal
> MDIO bus at all.
>
> Fixes: aab9c4067d23 ("net: dsa: Plug in PHYLINK support")
> Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Applied.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-03-26 18:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-23 23:24 [net-next] net: dsa: Avoid null pointer when failing to connect to PHY Vladimir Oltean
2019-03-24 1:17 ` Florian Fainelli
2019-03-26 18:27 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).