lkml.org 
[lkml]   [2018]   [Dec]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH v2 2/8] phy: mvebu-cp110-comphy: fix port check in ->xlate()
Hi Russell,

Russell King - ARM Linux <linux@armlinux.org.uk> wrote on Fri, 30 Nov
2018 19:00:31 +0000:

> On Fri, Nov 30, 2018 at 03:47:37PM +0100, Miquel Raynal wrote:
> > So far the PHY ->xlate() callback was checking if the port was
> > "invalid" before continuing, meaning that the port has not been used
> > yet. This check is not correct as there is no opposite call to
> > ->xlate() once the PHY is released by the user and the port will
> > remain "valid" after the first phy_get()/phy_put() calls. Hence, if
> > this driver is built as a module, inserted, removed and inserted
> > again, the PHY will appear busy and the second probe will fail.
> >
> > To fix this, just drop the faulty check and instead verify that the
> > port number is valid (ie. in the possible range).
> >
> > Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
> > ---
> > drivers/phy/marvell/phy-mvebu-cp110-comphy.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/phy/marvell/phy-mvebu-cp110-comphy.c b/drivers/phy/marvell/phy-mvebu-cp110-comphy.c
> > index 31b9a1c18345..a40b876ff214 100644
> > --- a/drivers/phy/marvell/phy-mvebu-cp110-comphy.c
> > +++ b/drivers/phy/marvell/phy-mvebu-cp110-comphy.c
> > @@ -567,9 +567,9 @@ static struct phy *mvebu_comphy_xlate(struct device *dev,
> > return phy;
> >
> > lane = phy_get_drvdata(phy);
> > - if (lane->port >= 0)
> > - return ERR_PTR(-EBUSY);
> > lane->port = args->args[0];
> > + if (lane->port >= MVEBU_COMPHY_PORTS)
> > + return ERR_PTR(-EINVAL);
>
> Shouldn't we validate args->args[0] before doing anything?
>

I don't understand your point, there is a check on args->args[0] as
we check its value (through lane->port) right after. What do you
have in mind?


Thanks,
Miquèl

\
 
 \ /
  Last update: 2018-12-02 20:36    [W:0.067 / U:4.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site