netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: phy: phylink: Handle NULL fwnode_handle
@ 2017-12-14 23:57 Florian Fainelli
  2017-12-15  0:25 ` Russell King - ARM Linux
  2017-12-15 18:51 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Florian Fainelli @ 2017-12-14 23:57 UTC (permalink / raw)
  To: netdev; +Cc: rmk+kernel, Florian Fainelli, Andrew Lunn, open list

Unlike the various of_* routines to fetch properties, fwnode_* routines can
have an early check against a NULL fwnode_handle reference which makes them
return -EINVAL (see fwnode_call_int_op), thus making it virtually impossible to
differentiate what type of error is going on.

Have an early check in phylink_register_sfp() so we can keep proceeding with
the initialization, there is not much we can do without a valid fwnode_handle
except return early and treat this similarly to -ENOENT.

Fixes: 8fa7b9b6af25 ("phylink: convert to fwnode")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/phy/phylink.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index c89b8c63f16a..69adc0aa141c 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -506,6 +506,9 @@ static int phylink_register_sfp(struct phylink *pl,
 	struct fwnode_reference_args ref;
 	int ret;
 
+	if (!fwnode)
+		return 0;
+
 	ret = fwnode_property_get_reference_args(fwnode, "sfp", NULL,
 						 0, 0, &ref);
 	if (ret < 0) {
-- 
2.14.1

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

* Re: [PATCH net-next] net: phy: phylink: Handle NULL fwnode_handle
  2017-12-14 23:57 [PATCH net-next] net: phy: phylink: Handle NULL fwnode_handle Florian Fainelli
@ 2017-12-15  0:25 ` Russell King - ARM Linux
  2017-12-15 18:51 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Russell King - ARM Linux @ 2017-12-15  0:25 UTC (permalink / raw)
  To: Florian Fainelli; +Cc: netdev, Andrew Lunn, open list

On Thu, Dec 14, 2017 at 03:57:58PM -0800, Florian Fainelli wrote:
> Unlike the various of_* routines to fetch properties, fwnode_* routines can
> have an early check against a NULL fwnode_handle reference which makes them
> return -EINVAL (see fwnode_call_int_op), thus making it virtually impossible to
> differentiate what type of error is going on.
> 
> Have an early check in phylink_register_sfp() so we can keep proceeding with
> the initialization, there is not much we can do without a valid fwnode_handle
> except return early and treat this similarly to -ENOENT.
> 
> Fixes: 8fa7b9b6af25 ("phylink: convert to fwnode")
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>

Acked-by: Russell King <rmk+kernel@armlinux.org.uk>

Thanks Florian.

> ---
>  drivers/net/phy/phylink.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
> index c89b8c63f16a..69adc0aa141c 100644
> --- a/drivers/net/phy/phylink.c
> +++ b/drivers/net/phy/phylink.c
> @@ -506,6 +506,9 @@ static int phylink_register_sfp(struct phylink *pl,
>  	struct fwnode_reference_args ref;
>  	int ret;
>  
> +	if (!fwnode)
> +		return 0;
> +
>  	ret = fwnode_property_get_reference_args(fwnode, "sfp", NULL,
>  						 0, 0, &ref);
>  	if (ret < 0) {
> -- 
> 2.14.1
> 

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up
According to speedtest.net: 8.21Mbps down 510kbps up

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

* Re: [PATCH net-next] net: phy: phylink: Handle NULL fwnode_handle
  2017-12-14 23:57 [PATCH net-next] net: phy: phylink: Handle NULL fwnode_handle Florian Fainelli
  2017-12-15  0:25 ` Russell King - ARM Linux
@ 2017-12-15 18:51 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2017-12-15 18:51 UTC (permalink / raw)
  To: f.fainelli; +Cc: netdev, rmk+kernel, andrew, linux-kernel

From: Florian Fainelli <f.fainelli@gmail.com>
Date: Thu, 14 Dec 2017 15:57:58 -0800

> Unlike the various of_* routines to fetch properties, fwnode_* routines can
> have an early check against a NULL fwnode_handle reference which makes them
> return -EINVAL (see fwnode_call_int_op), thus making it virtually impossible to
> differentiate what type of error is going on.
> 
> Have an early check in phylink_register_sfp() so we can keep proceeding with
> the initialization, there is not much we can do without a valid fwnode_handle
> except return early and treat this similarly to -ENOENT.
> 
> Fixes: 8fa7b9b6af25 ("phylink: convert to fwnode")
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>

Applied.

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

end of thread, other threads:[~2017-12-15 18:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-14 23:57 [PATCH net-next] net: phy: phylink: Handle NULL fwnode_handle Florian Fainelli
2017-12-15  0:25 ` Russell King - ARM Linux
2017-12-15 18:51 ` David Miller

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).