* [PATCH stable 4.9] net: mdio-mux: fix unbalanced put_device
@ 2021-11-17 18:03 Florian Fainelli
2021-11-17 18:20 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Florian Fainelli @ 2021-11-17 18:03 UTC (permalink / raw)
To: stable
Cc: Corentin Labbe, Andrew Lunn, David S . Miller, Florian Fainelli,
open list:ETHERNET PHY LIBRARY, open list
From: Corentin Labbe <clabbe.montjoie@gmail.com>
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>
---
Note: this patch did not get any fixes tag, but it does fix issues
introduced by fdf3b78df4d2 ("mdio: mux: Correct mdio_mux_init error
path issues").
Thanks!
drivers/net/phy/mdio-mux.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/phy/mdio-mux.c b/drivers/net/phy/mdio-mux.c
index 599ce24c514f..456b64248e5d 100644
--- a/drivers/net/phy/mdio-mux.c
+++ b/drivers/net/phy/mdio-mux.c
@@ -117,6 +117,7 @@ int mdio_mux_init(struct device *dev,
} else {
parent_bus_node = NULL;
parent_bus = mux_bus;
+ get_device(&parent_bus->dev);
}
pb = devm_kzalloc(dev, sizeof(*pb), GFP_KERNEL);
@@ -182,9 +183,7 @@ int mdio_mux_init(struct device *dev,
devm_kfree(dev, pb);
err_pb_kz:
- /* balance the reference of_mdio_find_bus() took */
- if (!mux_bus)
- put_device(&parent_bus->dev);
+ put_device(&parent_bus->dev);
err_parent_bus:
of_node_put(parent_bus_node);
return ret_val;
@@ -202,7 +201,6 @@ void mdio_mux_uninit(void *mux_handle)
cb = cb->next;
}
- /* balance the reference of_mdio_find_bus() in mdio_mux_init() took */
put_device(&pb->mii_bus->dev);
}
EXPORT_SYMBOL_GPL(mdio_mux_uninit);
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH stable 4.9] net: mdio-mux: fix unbalanced put_device
2021-11-17 18:03 [PATCH stable 4.9] net: mdio-mux: fix unbalanced put_device Florian Fainelli
@ 2021-11-17 18:20 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2021-11-17 18:20 UTC (permalink / raw)
To: Florian Fainelli
Cc: stable, Corentin Labbe, Andrew Lunn, David S . Miller,
open list:ETHERNET PHY LIBRARY, open list
On Wed, Nov 17, 2021 at 10:03:08AM -0800, Florian Fainelli wrote:
> From: Corentin Labbe <clabbe.montjoie@gmail.com>
>
> 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>
> ---
> Note: this patch did not get any fixes tag, but it does fix issues
> introduced by fdf3b78df4d2 ("mdio: mux: Correct mdio_mux_init error
> path issues").
Now queued up, thanks.
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-11-17 18:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-17 18:03 [PATCH stable 4.9] net: mdio-mux: fix unbalanced put_device Florian Fainelli
2021-11-17 18:20 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).