Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1219625

Re: [PATCH] net: phy: Handle postive return codes in phy_connect

From Michael Welling <mwelling@ieee.org>
Newsgroups linux.kernel
Subject Re: [PATCH] net: phy: Handle postive return codes in phy_connect
Date 2015-09-05 21:50 +0200
Message-ID <q5rDj-1Dm-1@gated-at.bofh.it> (permalink)
References <q5q4x-81k-7@gated-at.bofh.it> <q5rjY-1gU-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Sat, Sep 05, 2015 at 09:18:40PM +0200, Andrew Lunn wrote:
> On Sat, Sep 05, 2015 at 01:01:29PM -0500, Michael Welling wrote:
> > The function phy_connect_direct can possibly return a positive
> > return code. Using ERR_PTR with a positive value can lead to
> > deferencing of an invalid pointer.
> 
> Is this the correct fix? Would it not be better to find where the
> positive return code is from and fix that?

I guess I can trace it back to find out where the positive return code
is originating.

Is phy_connect_direct always supposed to return valid -errno?

> 
> 	 Andrew
> 
> > Signed-off-by: Michael Welling <mwelling@ieee.org>
> > ---
> >  drivers/net/phy/phy_device.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> > index c0f2111..a7e14a6 100644
> > --- a/drivers/net/phy/phy_device.c
> > +++ b/drivers/net/phy/phy_device.c
> > @@ -477,6 +477,9 @@ struct phy_device *phy_connect(struct net_device *dev, const char *bus_id,
> >  	phydev = to_phy_device(d);
> >  
> >  	rc = phy_connect_direct(dev, phydev, handler, interface);
> > +	if (rc > 0)
> > +		return ERR_PTR(-ENODEV);
> > +
> >  	if (rc)
> >  		return ERR_PTR(rc);
> >  
> > -- 
> > 2.1.4
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe netdev" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] net: phy: Handle postive return codes in phy_connect Michael Welling <mwelling@ieee.org> - 2015-09-05 20:10 +0200
  Re: [PATCH] net: phy: Handle postive return codes in phy_connect Andrew Lunn <andrew@lunn.ch> - 2015-09-05 21:30 +0200
    Re: [PATCH] net: phy: Handle postive return codes in phy_connect Michael Welling <mwelling@ieee.org> - 2015-09-05 21:50 +0200
      Re: [PATCH] net: phy: Handle postive return codes in phy_connect Andrew Lunn <andrew@lunn.ch> - 2015-09-05 22:00 +0200
        Re: [PATCH] net: phy: Handle postive return codes in phy_connect Florian Fainelli <f.fainelli@gmail.com> - 2015-09-05 22:20 +0200
          Re: [PATCH] net: phy: Handle postive return codes in phy_connect Michael Welling <mwelling@ieee.org> - 2015-09-05 22:30 +0200
        Re: [PATCH] net: phy: Handle postive return codes in phy_connect Michael Welling <mwelling@ieee.org> - 2015-09-05 22:30 +0200
          Re: [PATCH] net: phy: Handle postive return codes in phy_connect Andrew Lunn <andrew@lunn.ch> - 2015-09-05 22:40 +0200

csiph-web