Skip to content

Commit

Permalink
net: dsa: qca8k: put MDIO controller OF node if unavailable
Browse files Browse the repository at this point in the history
[ Upstream commit 0893232 ]

It was pointed out during the review [1] of commit e66bf63 ("net:
dsa: qca8k: skip MDIO bus creation if its OF node has status =
"disabled"") that we now leak a reference to the "mdio" OF node if it is
disabled.

This is only a concern when using dynamic OF as far as I can tell (like
probing on an overlay), since OF nodes are never freed in the regular
case. Additionally, I'm unaware of any actual device trees (in
production or elsewhere) which have status = "disabled" for the MDIO OF
node. So handling this as a simple enhancement.

[1] https://lore.kernel.org/netdev/CAJq09z4--Ug+3FAmp=EimQ8HTQYOWOuVon-PUMGB5a1N=RPv4g@mail.gmail.com/

Suggested-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
vladimiroltean authored and gregkh committed Apr 13, 2024
1 parent 649e24f commit 8d390b8
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/net/dsa/qca/qca8k-8xxx.c
Expand Up @@ -954,7 +954,7 @@ qca8k_mdio_register(struct qca8k_priv *priv)

mdio = of_get_child_by_name(dev->of_node, "mdio");
if (mdio && !of_device_is_available(mdio))
goto out;
goto out_put_node;

bus = devm_mdiobus_alloc(dev);
if (!bus) {
Expand Down Expand Up @@ -988,7 +988,6 @@ qca8k_mdio_register(struct qca8k_priv *priv)

out_put_node:
of_node_put(mdio);
out:
return err;
}

Expand Down

0 comments on commit 8d390b8

Please sign in to comment.