]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
of_mdio: fix node leak in of_phy_register_fixed_link error path
authorJohan Hovold <johan@kernel.org>
Wed, 16 Nov 2016 14:20:36 +0000 (15:20 +0100)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 23 Feb 2017 03:54:37 +0000 (03:54 +0000)
commit 48c1699d5335bc045b50989a06b1c526b17a25ff upstream.

Make sure to drop the of_node reference also on failure to parse the
speed property in of_phy_register_fixed_link().

Fixes: 3be2a49e5c08 ("of: provide a binding for fixed link PHYs")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/of/of_mdio.c

index 401b2453da45ae033c7d334dff28679284202765..a89699b5e22f25be9817da3ef0fc0494be0703e6 100644 (file)
@@ -291,8 +291,11 @@ int of_phy_register_fixed_link(struct device_node *np)
                status.link = 1;
                status.duplex = of_property_read_bool(fixed_link_node,
                                                      "full-duplex");
-               if (of_property_read_u32(fixed_link_node, "speed", &status.speed))
+               if (of_property_read_u32(fixed_link_node, "speed",
+                                        &status.speed)) {
+                       of_node_put(fixed_link_node);
                        return -EINVAL;
+               }
                status.pause = of_property_read_bool(fixed_link_node, "pause");
                status.asym_pause = of_property_read_bool(fixed_link_node,
                                                          "asym-pause");