net: sfp: ignore disabled SFP node
authorMarek Behún <kabel@kernel.org>
Wed, 19 Jan 2022 16:44:55 +0000 (17:44 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 8 Feb 2022 17:16:25 +0000 (18:16 +0100)
commit 2148927e6ed43a1667baf7c2ae3e0e05a44b51a0 upstream.

Commit ce0aa27ff3f6 ("sfp: add sfp-bus to bridge between network devices
and sfp cages") added code which finds SFP bus DT node even if the node
is disabled with status = "disabled". Because of this, when phylink is
created, it ends with non-null .sfp_bus member, even though the SFP
module is not probed (because the node is disabled).

We need to ignore disabled SFP bus node.

Fixes: ce0aa27ff3f6 ("sfp: add sfp-bus to bridge between network devices and sfp cages")
Signed-off-by: Marek Behún <kabel@kernel.org>
Cc: stable@vger.kernel.org # 2203cbf2c8b5 ("net: sfp: move fwnode parsing into sfp-bus layer")
Signed-off-by: David S. Miller <davem@davemloft.net>
[ backport to 4.14 ]
Signed-off-by: Marek Behún <kabel@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/phy/phylink.c

index 89d8efe8753e5969c67b04e1cb34e3b0fdfd2d44..a045fb3a698be591675b9bacfa92b20f9d06e1d3 100644 (file)
@@ -514,6 +514,11 @@ static int phylink_register_sfp(struct phylink *pl, struct device_node *np)
        if (!sfp_np)
                return 0;
 
+       if (!of_device_is_available(sfp_np)) {
+               of_node_put(sfp_np);
+               return 0;
+       }
+
        pl->sfp_bus = sfp_register_upstream(sfp_np, pl->netdev, pl,
                                            &sfp_phylink_ops);
        if (!pl->sfp_bus)