net: mdio-mux: fix unbalanced put_device
authorCorentin Labbe <clabbe.montjoie@gmail.com>
Fri, 1 Sep 2017 11:56:04 +0000 (13:56 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 26 Nov 2021 10:48:40 +0000 (11:48 +0100)
commit5ae4974c95795ad60791f9223b61a0c084fec7b2
tree3049b9d58e909b026b90036d5a6ed3e1750a912f
parent2a75be38913acf169cc01b4978b0e87f6342e85a
net: mdio-mux: fix unbalanced put_device

commit 60f786525032432af1b7d9b8935cb12936244ccd upstream.

mdio_mux_uninit() call put_device (unconditionally) because of
of_mdio_find_bus() in mdio_mux_init.
But of_mdio_find_bus is only called if mux_bus is empty.
If mux_bus is set, mdio_mux_uninit will print a "refcount_t: underflow"
trace.

This patch add a get_device in the other branch of "if (mux_bus)".

Signed-off-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/phy/mdio-mux.c