Jon Mason b601616681 mdio: mux: Correct mdio_mux_init error path issues
There is a potential unnecessary refcount decrement on error path of
put_device(&pb->mii_bus->dev), as it is possible to avoid the
of_mdio_find_bus() call if mux_bus is specified by the calling function.

The same put_device() is not called in the error path if the
devm_kzalloc of pb fails.  This caused the variable used in the
put_device() to be changed, as the pb pointer was obviously not set up.

There is an unnecessary of_node_get() on child_bus_node if the
of_mdiobus_register() is successful, as the
for_each_available_child_of_node() automatically increments this.
Thus the refcount on this node will always be +1 more than it should be.

There is no of_node_put() on child_bus_node if the of_mdiobus_register()
call fails.

Finally, it is lacking devm_kfree() of pb in the error path.  While this
might not be technically necessary, it was present in other parts of the
function.  So, I am adding it where necessary to make it uniform.

Signed-off-by: Jon Mason <jon.mason@broadcom.com>
Fixes: f20e6657a875 ("mdio: mux: Enhanced MDIO mux framework for integrated multiplexers")
Fixes: 0ca2997d1452 ("netdev/of/phy: Add MDIO bus multiplexer support.")
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-05-11 12:32:43 -04:00
..
2017-05-09 15:15:47 -07:00
2017-05-09 10:01:15 -07:00
2017-05-09 15:15:47 -07:00
2017-05-09 10:07:33 -07:00
2017-05-05 18:49:20 -07:00
2017-05-09 15:40:28 -07:00
2017-05-09 10:01:15 -07:00
2017-05-04 19:15:35 -07:00
2017-05-04 19:15:35 -07:00
2017-04-30 11:45:31 -07:00
2017-05-05 18:16:23 -07:00
2017-05-09 15:15:47 -07:00
2017-05-04 19:15:35 -07:00
2017-05-09 15:15:47 -07:00
2017-05-05 19:33:07 -07:00
2017-05-09 15:15:47 -07:00
2017-05-03 12:16:25 -07:00
2017-04-27 11:54:49 +01:00
2017-05-08 19:03:25 -07:00
2017-05-02 17:34:32 -07:00
2017-05-08 19:03:25 -07:00
2017-05-09 10:01:15 -07:00
2017-05-09 15:15:47 -07:00
2017-05-09 15:15:47 -07:00
2017-05-04 19:15:35 -07:00
2017-05-01 14:13:28 -07:00
2017-05-04 19:15:35 -07:00
2017-05-09 10:01:15 -07:00
2017-05-09 15:15:47 -07:00
2017-05-03 12:16:25 -07:00
2017-05-08 18:49:23 -07:00
2017-05-05 19:33:07 -07:00
2017-05-05 11:36:44 -07:00
2017-05-08 19:03:25 -07:00