Subject: Re: [PATCH net 2/2] sh_eth: Fix ethtool operation crash when net device is down

From: Florian Fainelli <[email-masked]>
Date: Mon, 19 Jan 2015 09:28:06 -0800

On 19/01/15 02:41, Ben Hutchings wrote:
> On Fri, 2015-01-16 at 10:45 -0800, Florian Fainelli wrote:
>> 2015-01-16 9:51 GMT-08:00 Ben Hutchings <[email-masked]>:
> [...]
>>> --- a/drivers/net/ethernet/renesas/sh_eth.c
>>> +++ b/drivers/net/ethernet/renesas/sh_eth.c
>>> @@ -1827,6 +1827,9 @@ static int sh_eth_get_settings(struct net_device *ndev,
>>>         unsigned long flags;
>>>         int ret;
>>>
>>> +       if (!mdp->phydev)
>>> +               return -ENODEV;
>>
>> Since the PHY is disconnected, would not checking for netif_running()
>> make sense here, unless there is a good reason to still allow
>> phy_ethtool_gset() to be called?
> [...]
> 
> I think those two conditions will be equivalent, won't they?

They are indeed.

>  Writing the condition like this will also work if the driver later supports
> PHY-less configurations.

You could also represent a PHY-less configuration by using the emulated
fixed-PHY, such that the driver is effectively "driving" a PHY device,
even though this is not a real one, up to you.
-- 
Florian