linux/drivers/net/mdio
Zeng Heng cb37617687 net: mdio: fix unbalanced fwnode reference count in mdio_device_release()
There is warning report about of_node refcount leak
while probing mdio device:

OF: ERROR: memory leak, expected refcount 1 instead of 2,
of_node_get()/of_node_put() unbalanced - destroy cset entry:
attach overlay node /spi/soc@0/mdio@710700c0/ethernet@4

In of_mdiobus_register_device(), we increase fwnode refcount
by fwnode_handle_get() before associating the of_node with
mdio device, but it has never been decreased in normal path.
Since that, in mdio_device_release(), it needs to call
fwnode_handle_put() in addition instead of calling kfree()
directly.

After above, just calling mdio_device_free() in the error handle
path of of_mdiobus_register_device() is enough to keep the
refcount balanced.

Fixes: a9049e0c51 ("mdio: Add support for mdio drivers.")
Signed-off-by: Zeng Heng <zengheng4@huawei.com>
Reviewed-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://lore.kernel.org/r/20221203073441.3885317-1-zengheng4@huawei.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2022-12-06 12:50:00 +01:00
..
acpi_mdio.c
fwnode_mdio.c net: mdiobus: fix double put fwnode in the error path 2022-12-05 11:00:25 +00:00
Kconfig
Makefile
mdio-aspeed.c
mdio-bcm-iproc.c
mdio-bcm-unimac.c
mdio-bitbang.c
mdio-cavium.c
mdio-cavium.h
mdio-gpio.c
mdio-hisi-femac.c
mdio-i2c.c net: phy: mdio-i2c: support I2C MDIO protocol for RollBall SFP modules 2022-10-03 11:08:33 +01:00
mdio-ipq4019.c
mdio-ipq8064.c
mdio-moxart.c
mdio-mscc-miim.c net: mdio: mscc-miim: add ability to be used in a non-mmio configuration 2022-09-09 07:54:32 +01:00
mdio-mux-bcm-iproc.c
mdio-mux-bcm6368.c
mdio-mux-gpio.c
mdio-mux-meson-g12a.c net: mdio: mux-meson-g12a: Switch to use dev_err_probe() helper 2022-09-20 08:41:19 -07:00
mdio-mux-mmioreg.c net: mdio: mux-mmioreg: Switch to use dev_err_probe() helper 2022-09-20 08:41:19 -07:00
mdio-mux-multiplexer.c net: mdio: mux-multiplexer: Switch to use dev_err_probe() helper 2022-09-20 08:41:20 -07:00
mdio-mux.c
mdio-mvusb.c
mdio-octeon.c
mdio-sun4i.c
mdio-thunder.c
mdio-xgene.c
of_mdio.c net: mdio: fix unbalanced fwnode reference count in mdio_device_release() 2022-12-06 12:50:00 +01:00