net: dsa: Add missing of_node_put() in dsa_port_link_register_of
authorMiaoqian Lin <linmq006@gmail.com>
Wed, 20 Apr 2022 11:04:08 +0000 (19:04 +0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 22 Apr 2022 12:06:58 +0000 (13:06 +0100)
The device_node pointer is returned by of_parse_phandle()  with refcount
incremented. We should use of_node_put() on it when done.
of_node_put() will check for NULL value.

Fixes: a20f997010c4 ("net: dsa: Don't instantiate phylink for CPU/DSA ports unless needed")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/dsa/port.c

index 32d472a8224194b1049205919676980d64970088..cdc56ba11f52b2eaa813d61addde078831813733 100644 (file)
@@ -1620,8 +1620,10 @@ int dsa_port_link_register_of(struct dsa_port *dp)
                        if (ds->ops->phylink_mac_link_down)
                                ds->ops->phylink_mac_link_down(ds, port,
                                        MLO_AN_FIXED, PHY_INTERFACE_MODE_NA);
+                       of_node_put(phy_np);
                        return dsa_port_phylink_register(dp);
                }
+               of_node_put(phy_np);
                return 0;
        }