net: mdio_bus: add refcounting for fwnodes to mdiobus
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Thu, 4 Jan 2024 10:37:55 +0000 (10:37 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 4 Jan 2024 11:24:55 +0000 (11:24 +0000)
commit3b73a7b8ec3821928cfaf399da7876bc39a5cf78
tree78653c7c78a8dd69394e82e0ac067e93ff06ebc3
parent0f2b21477988634ba7d813539f034d595f9501d7
net: mdio_bus: add refcounting for fwnodes to mdiobus

Luiz Angelo Daros de Luca reports that the MDIO bus code maintains a
reference to the DT node, but does not hold a refcount on the node.

The simple solution to this is to add the necessary refcounting into
the MDIO bus code for all users, ensuring that on registration, the
refcount is incremented, and only dropped when the MDIO bus is
released.

Do this for fwnodes, so we not only fix this for DT, but also other
types of firmware nodes as well.

Reported-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/mdio_bus.c