From: Florian Fainelli <f.fainelli@gmail.com>
To: Vladimir Oltean <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Russell King - ARM Linux admin <linux@armlinux.org.uk>,
Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>
Cc: netdev <netdev@vger.kernel.org>,
Alex Marginean <alexandru.marginean@nxp.com>
Subject: Re: [PATCH net-next] net: phy: don't crash in phy_read/_write_mmd without a PHY driver
Date: Thu, 16 Jan 2020 09:52:34 -0800 [thread overview]
Message-ID: <62029162-5a88-a015-90ad-d92bf2dc4d93@gmail.com> (raw)
In-Reply-To: <CA+h21hqyna1Fyr3ZQ7mwqUOw7rtUgfC3PqTqxg-HWFbDpNKDhg@mail.gmail.com>
On 1/16/20 9:48 AM, Vladimir Oltean wrote:
> On Thu, 16 Jan 2020 at 19:46, Vladimir Oltean <olteanv@gmail.com> wrote:
>>
>> From: Alex Marginean <alexandru.marginean@nxp.com>
>>
>> The APIs can be used by Ethernet drivers without actually loading a PHY
>> driver. This may become more widespread in the future with 802.3z
>> compatible MAC PCS devices being locally driven by the MAC driver when
>> configuring for a PHY mode with in-band negotiation.
>>
>> Check that drv is not NULL before reading from it.
>>
>> Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
>> ---
>
> Ugh. Can I just add here:
>
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
>
> without resending?
That's a tag that patchwork understands, so yes, that works:
http://patchwork.ozlabs.org/patch/1224348/mbox/
>
>> If this hasn't been reported by now I assume it wasn't an issue so far.
>> So I've targeted the patch for net-next and not provided a Fixes: tag.
>>
>> drivers/net/phy/phy-core.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/phy/phy-core.c b/drivers/net/phy/phy-core.c
>> index 769a076514b0..a4d2d59fceca 100644
>> --- a/drivers/net/phy/phy-core.c
>> +++ b/drivers/net/phy/phy-core.c
>> @@ -387,7 +387,7 @@ int __phy_read_mmd(struct phy_device *phydev, int devad, u32 regnum)
>> if (regnum > (u16)~0 || devad > 32)
>> return -EINVAL;
>>
>> - if (phydev->drv->read_mmd) {
>> + if (phydev->drv && phydev->drv->read_mmd) {
>> val = phydev->drv->read_mmd(phydev, devad, regnum);
>> } else if (phydev->is_c45) {
>> u32 addr = MII_ADDR_C45 | (devad << 16) | (regnum & 0xffff);
>> @@ -444,7 +444,7 @@ int __phy_write_mmd(struct phy_device *phydev, int devad, u32 regnum, u16 val)
>> if (regnum > (u16)~0 || devad > 32)
>> return -EINVAL;
>>
>> - if (phydev->drv->write_mmd) {
>> + if (phydev->drv && phydev->drv->write_mmd) {
>> ret = phydev->drv->write_mmd(phydev, devad, regnum, val);
>> } else if (phydev->is_c45) {
>> u32 addr = MII_ADDR_C45 | (devad << 16) | (regnum & 0xffff);
>> --
>> 2.17.1
>>
>
> Sorry,
> -Vladimir
>
--
Florian
next prev parent reply other threads:[~2020-01-16 17:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-16 17:46 [PATCH net-next] net: phy: don't crash in phy_read/_write_mmd without a PHY driver Vladimir Oltean
2020-01-16 17:48 ` Vladimir Oltean
2020-01-16 17:52 ` Florian Fainelli [this message]
2020-01-16 20:47 ` Heiner Kallweit
2020-01-16 20:51 ` Florian Fainelli
2020-01-20 9:08 ` David Miller
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=62029162-5a88-a015-90ad-d92bf2dc4d93@gmail.com \
--to=f.fainelli@gmail.com \
--cc=alexandru.marginean@nxp.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=hkallweit1@gmail.com \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.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).