linux-stable/net/dsa
Russell King e496ae690b net: dsa: fix of_mdio_find_bus() device refcount leak
Current users of of_mdio_find_bus() leak a struct device refcount, as
they fail to clean up the reference obtained inside class_find_device().

Fix the DSA code to properly refcount the returned MDIO bus by:
1. taking a reference on the struct device whenever we assign it to
   pd->chip[x].host_dev.
2. dropping the reference when we overwrite the existing reference.
3. dropping the reference when we free the data structure.
4. dropping the initial reference we obtained after setting up the
   platform data structure, or on failure.

In step 2 above, where we obtain a new MDIO bus, there is no need to
take a reference on it as we would only have to drop it immediately
after assignment again, iow:

	put_device(cd->host_dev);	/* drop original assignment ref */
	cd->host_dev = get_device(&mdio_bus_switch->dev); /* get our ref */
	put_device(&mdio_bus_switch->dev); /* drop of_mdio_find_bus ref */

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-09-24 23:04:52 -07:00
..
dsa.c net: dsa: fix of_mdio_find_bus() device refcount leak 2015-09-24 23:04:52 -07:00
dsa_priv.h net: dsa: Add netconsole support 2015-07-31 15:45:37 -07:00
Kconfig net: dsa: make NET_DSA manually selectable from the config 2015-03-20 21:37:58 -04:00
Makefile net: dsa: add Broadcom tag RX/TX handler 2014-08-27 22:59:40 -07:00
slave.c net: dsa: convert to using IFF_NO_QUEUE 2015-08-18 11:55:06 -07:00
tag_brcm.c net: dsa: Refactor transmit path to eliminate duplication 2015-07-31 15:45:37 -07:00
tag_dsa.c net: dsa: Refactor transmit path to eliminate duplication 2015-07-31 15:45:37 -07:00
tag_edsa.c net: dsa: Refactor transmit path to eliminate duplication 2015-07-31 15:45:37 -07:00
tag_trailer.c net: dsa: Fix Marvell Egress Trailer check 2015-09-22 17:37:03 -07:00