From: Florian Fainelli <f.fainelli@gmail.com>
To: maowenan <maowenan@huawei.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
"andrew@lunn.ch" <andrew@lunn.ch>,
"rmk+kernel@armlinux.org.uk" <rmk+kernel@armlinux.org.uk>
Subject: Re: [PATCH net v2 1/3] net: phy: Fix PHY module checks
Date: Wed, 8 Feb 2017 09:46:27 -0800 [thread overview]
Message-ID: <34e621b5-9fb7-aad5-126f-291b52af30be@gmail.com> (raw)
In-Reply-To: <F95AC9340317A84688A5F0DF0246F3F201ED9E4E@szxemi502-mbx.china.huawei.com>
On 02/07/2017 11:57 PM, maowenan wrote:
>
>
>> -----Original Message-----
>> From: Florian Fainelli [mailto:f.fainelli@gmail.com]
>> Sent: Wednesday, February 08, 2017 3:38 PM
>> To: netdev@vger.kernel.org
>> Cc: davem@davemloft.net; andrew@lunn.ch; rmk+kernel@armlinux.org.uk;
>> maowenan; Florian Fainelli
>> Subject: [PATCH net v2 1/3] net: phy: Fix PHY module checks
>>
>> The Generic PHY drivers gets assigned after we checked that the current PHY
>> driver is NULL, so we need to check a few things before we can safely
>> derference d->driver. Update phy_attach_direct() and phy_detach() accordingly
>> to be resilient to these cases.
>>
>> Even though the Generic PHY driver defaults to phy_probe() which can hardly
>> fail at the moment, let's fix the label so we don't call phy_detach() on a network
>> device we have not attached yet.
>>
>> Fixes: cafe8df8b9bc ("net: phy: Fix lack of reference count on PHY driver")
>> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
>> ---
>> drivers/net/phy/phy_device.c | 8 +++++---
>> 1 file changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index
>> 0d8f4d3847f6..bde240bf8d7b 100644
>> --- a/drivers/net/phy/phy_device.c
>> +++ b/drivers/net/phy/phy_device.c
>> @@ -920,7 +920,7 @@ int phy_attach_direct(struct net_device *dev, struct
>> phy_device *phydev,
>> return -EIO;
>> }
>>
>> - if (!try_module_get(d->driver->owner)) {
>> + if (d->driver && !try_module_get(d->driver->owner)) {
>> dev_err(&dev->dev, "failed to get the device driver module\n");
>> return -EIO;
>
> Hi Florian,
> Here "return -EIO" will miss decreasing bus->owner reference count.
Good catch thanks!
--
Florian
next prev parent reply other threads:[~2017-02-08 17:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-08 7:37 [PATCH net v2 0/3] net: phy: Unbind/bind fixes Florian Fainelli
2017-02-08 7:37 ` [PATCH net v2 1/3] net: phy: Fix PHY module checks Florian Fainelli
2017-02-08 7:57 ` maowenan
2017-02-08 17:46 ` Florian Fainelli [this message]
2017-02-08 16:46 ` Fabio Estevam
2017-02-08 16:57 ` Andrew Lunn
2017-02-08 17:55 ` Florian Fainelli
2017-02-08 7:37 ` [PATCH net v2 2/3] net: phy: Check phydev->drv Florian Fainelli
2017-02-08 7:37 ` [PATCH net v2 3/3] net: phy: Fix PHY driver bind and unbind events Florian Fainelli
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=34e621b5-9fb7-aad5-126f-291b52af30be@gmail.com \
--to=f.fainelli@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=maowenan@huawei.com \
--cc=netdev@vger.kernel.org \
--cc=rmk+kernel@armlinux.org.uk \
/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).