From: Russell King - ARM Linux <linux@armlinux.org.uk>
To: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Gregory Clement <gregory.clement@bootlin.com>,
Jason Cooper <jason@lakedaemon.net>, Andrew Lunn <andrew@lunn.ch>,
Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
Kishon Vijay Abraham I <kishon@ti.com>,
Mark Rutland <mark.rutland@arm.com>,
devicetree@vger.kernel.org,
Antoine Tenart <antoine.tenart@bootlin.com>,
Grzegorz Jaszczyk <jaz@semihalf.com>,
linux-kernel@vger.kernel.org,
Maxime Chevallier <maxime.chevallier@bootlin.com>,
Nadav Haklai <nadavh@marvell.com>,
Rob Herring <robh+dt@kernel.org>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Marcin Wojtas <mw@semihalf.com>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 2/8] phy: mvebu-cp110-comphy: fix port check in ->xlate()
Date: Fri, 30 Nov 2018 19:00:31 +0000 [thread overview]
Message-ID: <20181130190031.GH30658@n2100.armlinux.org.uk> (raw)
In-Reply-To: <20181130144743.675-3-miquel.raynal@bootlin.com>
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?
--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up
next prev parent reply other threads:[~2018-11-30 19:00 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-30 14:47 [PATCH v2 0/8] Add Armada 3700 COMPHY support Miquel Raynal
2018-11-30 14:47 ` [PATCH v2 1/8] phy: mvebu-cp110-comphy: fix spelling in structure name Miquel Raynal
2018-11-30 14:47 ` [PATCH v2 2/8] phy: mvebu-cp110-comphy: fix port check in ->xlate() Miquel Raynal
2018-11-30 19:00 ` Russell King - ARM Linux [this message]
2018-12-02 19:35 ` Miquel Raynal
2018-12-03 0:36 ` Russell King - ARM Linux
2018-12-03 13:56 ` Miquel Raynal
2018-11-30 14:47 ` [PATCH v2 3/8] phy: enumerate SATA PHY mode Miquel Raynal
2018-11-30 14:47 ` [PATCH v2 4/8] phy: add A3700 COMPHY support Miquel Raynal
2018-11-30 14:47 ` [PATCH v2 5/8] dt-bindings: phy: mvebu-comphy: extend the file to describe a3700 bindings Miquel Raynal
2018-11-30 14:47 ` [PATCH v2 6/8] MAINTAINERS: phy: add entry for Armada 3700 COMPHY driver Miquel Raynal
2018-11-30 14:47 ` [PATCH v2 7/8] ARM64: dts: marvell: armada-37xx: fix SATA node scope Miquel Raynal
2018-11-30 14:47 ` [PATCH v2 8/8] ARM64: dts: marvell: armada-37xx: declare the COMPHY node Miquel Raynal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181130190031.GH30658@n2100.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=andrew@lunn.ch \
--cc=antoine.tenart@bootlin.com \
--cc=devicetree@vger.kernel.org \
--cc=gregory.clement@bootlin.com \
--cc=jason@lakedaemon.net \
--cc=jaz@semihalf.com \
--cc=kishon@ti.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=maxime.chevallier@bootlin.com \
--cc=miquel.raynal@bootlin.com \
--cc=mw@semihalf.com \
--cc=nadavh@marvell.com \
--cc=robh+dt@kernel.org \
--cc=sebastian.hesselbarth@gmail.com \
--cc=thomas.petazzoni@bootlin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).