* [PATCH net 0/2] net: dsa: two small bug fixes
@ 2014-12-11 20:49 Florian Fainelli
2014-12-11 20:49 ` [PATCH net 1/2] net: dsa: handle non-existing PHYs on switch internal bus Florian Fainelli
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Florian Fainelli @ 2014-12-11 20:49 UTC (permalink / raw)
To: netdev; +Cc: davem, computersforpeace, andrey.volkov, Florian Fainelli
Hi David,
Here are two small fixes for the DSA slave interface creation code:
- first patch fixes a null pointer de-reference with an invalid PHY
device pointer while calling phy_connect_direct()
- second path propagates the dsa_slave_phy_setup() error code down to
its caller: dsa_slave_create
Thanks!
Florian Fainelli (2):
net: dsa: handle non-existing PHYs on switch internal bus
net: dsa: propagate error code from dsa_slave_phy_setup
net/dsa/slave.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
--
2.1.0
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH net 1/2] net: dsa: handle non-existing PHYs on switch internal bus 2014-12-11 20:49 [PATCH net 0/2] net: dsa: two small bug fixes Florian Fainelli @ 2014-12-11 20:49 ` Florian Fainelli 2014-12-16 10:24 ` Andrew Lunn 2014-12-11 20:49 ` [PATCH net 2/2] net: dsa: propagate error code from dsa_slave_phy_setup Florian Fainelli 2014-12-12 2:00 ` [PATCH net 0/2] net: dsa: two small bug fixes David Miller 2 siblings, 1 reply; 5+ messages in thread From: Florian Fainelli @ 2014-12-11 20:49 UTC (permalink / raw) To: netdev Cc: davem, computersforpeace, andrey.volkov, Florian Fainelli, Andrew Lunn In case there is no PHY at the designated address on the internal switch, we would basically de-reference a null pointer here: dsa_slave_phy_setup(...) { p->phy = ds->slave_mii_bus->phy_map[p->port]; phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link, ^------ This can be triggered when the platform configuration (platform_data or Device Tree) indicates there should be a PHY device at this address, but the HW is non-responsive, such that we cannot attach a PHY device at this specific location. Fix this by checking the return value prior to calling phy_connect_direct(). CC: Andrew Lunn <andrew@lunn.ch> Fixes: b31f65fb4383 ("net: dsa: slave: Fix autoneg for phys on switch MDIO bus") Reported-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Andrey Volkov <andrey.volkov@nexvision.fr> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> --- net/dsa/slave.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/dsa/slave.c b/net/dsa/slave.c index ab03e00ffe8f..0efaab1e408b 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -491,6 +491,9 @@ static void dsa_slave_phy_setup(struct dsa_slave_priv *p, */ if (!p->phy) { p->phy = ds->slave_mii_bus->phy_map[p->port]; + if (!p->phy) + return; + phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link, p->phy_interface); } else { -- 2.1.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net 1/2] net: dsa: handle non-existing PHYs on switch internal bus 2014-12-11 20:49 ` [PATCH net 1/2] net: dsa: handle non-existing PHYs on switch internal bus Florian Fainelli @ 2014-12-16 10:24 ` Andrew Lunn 0 siblings, 0 replies; 5+ messages in thread From: Andrew Lunn @ 2014-12-16 10:24 UTC (permalink / raw) To: Florian Fainelli Cc: netdev, davem, computersforpeace, andrey.volkov, Andrew Lunn On Thu, Dec 11, 2014 at 12:49:15PM -0800, Florian Fainelli wrote: > In case there is no PHY at the designated address on the internal > switch, we would basically de-reference a null pointer here: > > dsa_slave_phy_setup(...) > { > p->phy = ds->slave_mii_bus->phy_map[p->port]; > phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link, > ^------ > > This can be triggered when the platform configuration (platform_data or > Device Tree) indicates there should be a PHY device at this address, but > the HW is non-responsive, such that we cannot attach a PHY device at > this specific location. > > Fix this by checking the return value prior to calling > phy_connect_direct(). > > CC: Andrew Lunn <andrew@lunn.ch> > Fixes: b31f65fb4383 ("net: dsa: slave: Fix autoneg for phys on switch MDIO bus") > Reported-by: Brian Norris <computersforpeace@gmail.com> > Signed-off-by: Andrey Volkov <andrey.volkov@nexvision.fr> > Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Acked-by: Andrew Lunn <andrew@lunn.ch> Andrew > --- > net/dsa/slave.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/net/dsa/slave.c b/net/dsa/slave.c > index ab03e00ffe8f..0efaab1e408b 100644 > --- a/net/dsa/slave.c > +++ b/net/dsa/slave.c > @@ -491,6 +491,9 @@ static void dsa_slave_phy_setup(struct dsa_slave_priv *p, > */ > if (!p->phy) { > p->phy = ds->slave_mii_bus->phy_map[p->port]; > + if (!p->phy) > + return; > + > phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link, > p->phy_interface); > } else { > -- > 2.1.0 > ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net 2/2] net: dsa: propagate error code from dsa_slave_phy_setup 2014-12-11 20:49 [PATCH net 0/2] net: dsa: two small bug fixes Florian Fainelli 2014-12-11 20:49 ` [PATCH net 1/2] net: dsa: handle non-existing PHYs on switch internal bus Florian Fainelli @ 2014-12-11 20:49 ` Florian Fainelli 2014-12-12 2:00 ` [PATCH net 0/2] net: dsa: two small bug fixes David Miller 2 siblings, 0 replies; 5+ messages in thread From: Florian Fainelli @ 2014-12-11 20:49 UTC (permalink / raw) To: netdev; +Cc: davem, computersforpeace, andrey.volkov, Florian Fainelli In case we cannot attach to our slave netdevice PHY, error out and propagate that error up to the caller: dsa_slave_create(). Fixes: 0d8bcdd383b8 ("net: dsa: allow for more complex PHY setups") Signed-off-by: Andrey Volkov <andrey.volkov@nexvision.fr> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> --- net/dsa/slave.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 0efaab1e408b..646c24ce4501 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -448,7 +448,7 @@ static int dsa_slave_fixed_link_update(struct net_device *dev, } /* slave device setup *******************************************************/ -static void dsa_slave_phy_setup(struct dsa_slave_priv *p, +static int dsa_slave_phy_setup(struct dsa_slave_priv *p, struct net_device *slave_dev) { struct dsa_switch *ds = p->parent; @@ -469,7 +469,7 @@ static void dsa_slave_phy_setup(struct dsa_slave_priv *p, ret = of_phy_register_fixed_link(port_dn); if (ret) { pr_err("failed to register fixed PHY\n"); - return; + return ret; } phy_is_fixed = true; phy_dn = port_dn; @@ -492,7 +492,7 @@ static void dsa_slave_phy_setup(struct dsa_slave_priv *p, if (!p->phy) { p->phy = ds->slave_mii_bus->phy_map[p->port]; if (!p->phy) - return; + return -ENODEV; phy_connect_direct(slave_dev, p->phy, dsa_slave_adjust_link, p->phy_interface); @@ -500,6 +500,8 @@ static void dsa_slave_phy_setup(struct dsa_slave_priv *p, pr_info("attached PHY at address %d [%s]\n", p->phy->addr, p->phy->drv->name); } + + return 0; } int dsa_slave_suspend(struct net_device *slave_dev) @@ -592,12 +594,17 @@ dsa_slave_create(struct dsa_switch *ds, struct device *parent, p->old_link = -1; p->old_duplex = -1; - dsa_slave_phy_setup(p, slave_dev); + ret = dsa_slave_phy_setup(p, slave_dev); + if (ret) { + free_netdev(slave_dev); + return NULL; + } ret = register_netdev(slave_dev); if (ret) { printk(KERN_ERR "%s: error %d registering interface %s\n", master->name, ret, slave_dev->name); + phy_disconnect(p->phy); free_netdev(slave_dev); return NULL; } -- 2.1.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net 0/2] net: dsa: two small bug fixes 2014-12-11 20:49 [PATCH net 0/2] net: dsa: two small bug fixes Florian Fainelli 2014-12-11 20:49 ` [PATCH net 1/2] net: dsa: handle non-existing PHYs on switch internal bus Florian Fainelli 2014-12-11 20:49 ` [PATCH net 2/2] net: dsa: propagate error code from dsa_slave_phy_setup Florian Fainelli @ 2014-12-12 2:00 ` David Miller 2 siblings, 0 replies; 5+ messages in thread From: David Miller @ 2014-12-12 2:00 UTC (permalink / raw) To: f.fainelli; +Cc: netdev, computersforpeace, andrey.volkov From: Florian Fainelli <f.fainelli@gmail.com> Date: Thu, 11 Dec 2014 12:49:14 -0800 > Here are two small fixes for the DSA slave interface creation code: > > - first patch fixes a null pointer de-reference with an invalid PHY > device pointer while calling phy_connect_direct() > > - second path propagates the dsa_slave_phy_setup() error code down to > its caller: dsa_slave_create Series applied. Please give me some feedback on the FIXED_PHY Kconfig issue I asked you about earlier today. Thanks. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-12-16 10:25 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-12-11 20:49 [PATCH net 0/2] net: dsa: two small bug fixes Florian Fainelli 2014-12-11 20:49 ` [PATCH net 1/2] net: dsa: handle non-existing PHYs on switch internal bus Florian Fainelli 2014-12-16 10:24 ` Andrew Lunn 2014-12-11 20:49 ` [PATCH net 2/2] net: dsa: propagate error code from dsa_slave_phy_setup Florian Fainelli 2014-12-12 2:00 ` [PATCH net 0/2] net: dsa: two small bug fixes 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).