diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2015-09-24 19:35:57 (GMT) |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-09-25 06:04:52 (GMT) |
commit | e496ae690b2faff751e1849fb97b060615e21f28 (patch) | |
tree | e32e9642246190efcb59077b698a6398928f0d65 /include | |
parent | a136442131443d929d2d8d243157824de4dfbae8 (diff) | |
download | linux-e496ae690b2faff751e1849fb97b060615e21f28.tar.xz |
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>
Diffstat (limited to 'include')
0 files changed, 0 insertions, 0 deletions