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 net: mdio: Add ACPI support code for mdio 2021-06-11 13:08:53 -07:00
fwnode_mdio.c net: mdiobus: fix double put fwnode in the error path 2022-12-05 11:00:25 +00:00
Kconfig net: mdio: mscc-miim: Add depend of REGMAP_MMIO on MDIO_MSCC_MIIM 2021-12-01 18:46:54 -08:00
Makefile net: mdio: Add ACPI support code for mdio 2021-06-11 13:08:53 -07:00
mdio-aspeed.c net: mdio: add reset control for Aspeed MDIO 2022-04-28 09:39:31 +02:00
mdio-bcm-iproc.c
mdio-bcm-unimac.c net: mdio: Fix spelling mistakes 2021-06-01 17:05:05 -07:00
mdio-bitbang.c net: phy: Add support for microchip SMI0 MDIO bus 2021-04-27 14:13:24 -07:00
mdio-cavium.c
mdio-cavium.h
mdio-gpio.c net: phy: Add support for microchip SMI0 MDIO bus 2021-04-27 14:13:24 -07:00
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 net: mdio-ipq4019: add delay after clock enable 2022-02-21 13:04:53 +00:00
mdio-ipq8064.c net: mdio: ipq8064: replace ioremap() with devm_ioremap() 2021-11-29 12:02:49 +00:00
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-bcm6368.c net: mdio: Fix ENOMEM return value in BCM6368 mux bus controller 2022-04-29 17:58:41 -07:00
mdio-mux-bcm-iproc.c net: mido: mdio-mux-bcm-iproc: Use devm_platform_get_and_ioremap_resource() 2021-06-10 13:59:37 -07:00
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 net: mdio-mux: add bus name to bus id 2022-03-08 10:28:25 +01:00
mdio-mvusb.c
mdio-octeon.c net: mdio: octeon: Fix some double free issues 2021-05-13 15:43:52 -07:00
mdio-sun4i.c
mdio-thunder.c net: mdio: thunder: Fix a double free issue in the .remove function 2021-05-13 13:13:34 -07:00
mdio-xgene.c drivers: net: Replace acpi_bus_get_device() 2022-02-02 08:05:06 -08:00
of_mdio.c net: mdio: fix unbalanced fwnode reference count in mdio_device_release() 2022-12-06 12:50:00 +01:00