All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] phy: check if parent device is NULL
@ 2016-12-20 23:51 Ruslan Babayev
  2016-12-21  0:33 ` Florian Fainelli
  0 siblings, 1 reply; 3+ messages in thread
From: Ruslan Babayev @ 2016-12-20 23:51 UTC (permalink / raw)
  To: netdev; +Cc: f.fainelli

Fixes a crash observed on Octeon.

Signed-off-by: Ruslan Babayev <ruslan@babayev.com>
Fixes: ec988ad78ed6 ("phy: Don't increment MDIO bus refcount unless it's a
different owner")
---
 drivers/net/phy/phy_device.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 9c06f8028f0c..043328b85643 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -905,7 +905,8 @@ EXPORT_SYMBOL(phy_attached_print);
 int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
 		      u32 flags, phy_interface_t interface)
 {
-	struct module *ndev_owner = dev->dev.parent->driver->owner;
+	struct device *parent = dev->dev.parent;
+	struct module *ndev_owner = parent ? parent->driver->owner : NULL;
 	struct mii_bus *bus = phydev->mdio.bus;
 	struct device *d = &phydev->mdio.dev;
 	int err;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] phy: check if parent device is NULL
  2016-12-20 23:51 [PATCH] phy: check if parent device is NULL Ruslan Babayev
@ 2016-12-21  0:33 ` Florian Fainelli
  2016-12-21  2:35   ` Ruslan Babayev
  0 siblings, 1 reply; 3+ messages in thread
From: Florian Fainelli @ 2016-12-21  0:33 UTC (permalink / raw)
  To: Ruslan Babayev, netdev

On 12/20/2016 03:51 PM, Ruslan Babayev wrote:
> Fixes a crash observed on Octeon.
> 
> Signed-off-by: Ruslan Babayev <ruslan@babayev.com>
> Fixes: ec988ad78ed6 ("phy: Don't increment MDIO bus refcount unless it's a
> different owner")

Assuming you saw this with the staging Octeon driver, a fix has already
been submitted:

https://lkml.org/lkml/2016/12/14/756

If this is with a different driver, I would rather we fix it in a
similar way that the fix proposed above.

Thanks

> ---
>  drivers/net/phy/phy_device.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index 9c06f8028f0c..043328b85643 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
> @@ -905,7 +905,8 @@ EXPORT_SYMBOL(phy_attached_print);
>  int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
>  		      u32 flags, phy_interface_t interface)
>  {
> -	struct module *ndev_owner = dev->dev.parent->driver->owner;
> +	struct device *parent = dev->dev.parent;
> +	struct module *ndev_owner = parent ? parent->driver->owner : NULL;
>  	struct mii_bus *bus = phydev->mdio.bus;
>  	struct device *d = &phydev->mdio.dev;
>  	int err;
> 


-- 
Florian

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] phy: check if parent device is NULL
  2016-12-21  0:33 ` Florian Fainelli
@ 2016-12-21  2:35   ` Ruslan Babayev
  0 siblings, 0 replies; 3+ messages in thread
From: Ruslan Babayev @ 2016-12-21  2:35 UTC (permalink / raw)
  To: Florian Fainelli; +Cc: netdev

Yes, I saw that with the staging Octeon driver.
Your patch works for me too.

Thanks Florian!


On Tue, Dec 20, 2016 at 4:33 PM, Florian Fainelli <f.fainelli@gmail.com> wrote:
> On 12/20/2016 03:51 PM, Ruslan Babayev wrote:
>> Fixes a crash observed on Octeon.
>>
>> Signed-off-by: Ruslan Babayev <ruslan@babayev.com>
>> Fixes: ec988ad78ed6 ("phy: Don't increment MDIO bus refcount unless it's a
>> different owner")
>
> Assuming you saw this with the staging Octeon driver, a fix has already
> been submitted:
>
> https://lkml.org/lkml/2016/12/14/756
>
> If this is with a different driver, I would rather we fix it in a
> similar way that the fix proposed above.
>
> Thanks
>
>> ---
>>  drivers/net/phy/phy_device.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
>> index 9c06f8028f0c..043328b85643 100644
>> --- a/drivers/net/phy/phy_device.c
>> +++ b/drivers/net/phy/phy_device.c
>> @@ -905,7 +905,8 @@ EXPORT_SYMBOL(phy_attached_print);
>>  int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
>>                     u32 flags, phy_interface_t interface)
>>  {
>> -     struct module *ndev_owner = dev->dev.parent->driver->owner;
>> +     struct device *parent = dev->dev.parent;
>> +     struct module *ndev_owner = parent ? parent->driver->owner : NULL;
>>       struct mii_bus *bus = phydev->mdio.bus;
>>       struct device *d = &phydev->mdio.dev;
>>       int err;
>>
>
>
> --
> Florian

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-12-21  2:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-20 23:51 [PATCH] phy: check if parent device is NULL Ruslan Babayev
2016-12-21  0:33 ` Florian Fainelli
2016-12-21  2:35   ` Ruslan Babayev

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.