mirror-linux/drivers/net/mdio
Yang Yingliang cdde156011 net: mdiobus: fix unbalanced node reference count
I got the following report while doing device(mscc-miim) load test
with CONFIG_OF_UNITTEST and CONFIG_OF_DYNAMIC enabled:

  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@7107009c/ethernet-phy@0

If the 'fwnode' is not an acpi node, the refcount is get in
fwnode_mdiobus_phy_device_register(), but it has never been
put when the device is freed in the normal path. So call
fwnode_handle_put() in phy_device_release() to avoid leak.

If it's an acpi node, it has never been get, but it's put
in the error path, so call fwnode_handle_get() before
phy_device_register() to keep get/put operation balanced.

Fixes: bc1bee3b87 ("net: mdiobus: Introduce fwnode_mdiobus_register_phy()")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://lore.kernel.org/r/20221124150130.609420-1-yangyingliang@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2022-11-28 18:10:25 -08:00
..
Kconfig net: mdio: mscc-miim: Add depend of REGMAP_MMIO on MDIO_MSCC_MIIM 2021-12-01 18:46:54 -08:00
Makefile
acpi_mdio.c
fwnode_mdio.c net: mdiobus: fix unbalanced node reference count 2022-11-28 18:10:25 -08: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
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 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-bcm-iproc.c
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-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
mdio-sun4i.c
mdio-thunder.c
mdio-xgene.c drivers: net: Replace acpi_bus_get_device() 2022-02-02 08:05:06 -08:00
of_mdio.c of: mdio: Add of_node_put() when breaking out of for_each_xx 2022-09-20 07:32:09 -07:00