lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 18 Aug 2021 22:11:37 +0200
From:   Gerhard Engleder <gerhard@...leder-embedded.com>
To:     Andrew Lunn <andrew@...n.ch>
Cc:     netdev <netdev@...r.kernel.org>
Subject: Re: [PATCH net-next 1/2] net: phy: Support set_loopback override

On Wed, Aug 18, 2021 at 5:03 PM Andrew Lunn <andrew@...n.ch> wrote:
>
> On Wed, Aug 18, 2021 at 02:27:35PM +0200, Gerhard Engleder wrote:
> > phy_read_status and various other PHY functions support PHY specific
> > overriding of driver functions by using a PHY specific pointer to the
> > PHY driver. Add support of PHY specific override to phy_loopback too.
> >
> > Signed-off-by: Gerhard Engleder <gerhard@...leder-embedded.com>
> > ---
> >  drivers/net/phy/phy_device.c | 9 ++++-----
> >  1 file changed, 4 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> > index 107aa6d7bc6b..ba5ad86ec826 100644
> > --- a/drivers/net/phy/phy_device.c
> > +++ b/drivers/net/phy/phy_device.c
> > @@ -1821,11 +1821,10 @@ EXPORT_SYMBOL(phy_resume);
> >
> >  int phy_loopback(struct phy_device *phydev, bool enable)
> >  {
> > -     struct phy_driver *phydrv = to_phy_driver(phydev->mdio.dev.driver);
> >       int ret = 0;
> >
> > -     if (!phydrv)
> > -             return -ENODEV;
> > +     if (!phydev->drv)
> > +             return -EIO;
>
> Humm, we need to take a closer look at what uses to_phy_driver() and
> what uses phydev->drv. Do they need to be different? Can we make it
> uniform?
>
>         Andrew

I saw only 4 references for to_phy_driver():
- phy_loopback() of course
- phy_probe() which uses it to initialize phydev->drv 3 lines later
- mdio_bus_phy_may_suspend() which checks only for valid suspend function
  pointer, but later phy_suspend() uses phydev->drv, so this is at
least inconsistent
- phy_bus_match() which casts from struct device_driver to struct phy_driver

phydev->drv is used much more often and seems to be the right way. I suggest to
also fix mdio_bus_phy_may_suspend(). phy_probe() and phy_bus_match() are
valid uses, because phydev->drv is not available for them.

Do you agree?

Gerhard

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ