* [PATCH v2] net: dsa: mv88e6xxx: Fix refcount leak in mv88e6xxx_mdios_register
@ 2022-05-26 11:24 Miaoqian Lin
2022-05-26 12:18 ` Andrew Lunn
0 siblings, 1 reply; 2+ messages in thread
From: Miaoqian Lin @ 2022-05-26 11:24 UTC (permalink / raw)
To: Andrew Lunn, Vivien Didelot, Florian Fainelli, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
netdev, linux-kernel
Cc: linmq006
of_get_child_by_name() returns a node pointer with refcount
incremented, we should use of_node_put() on it when done.
This function missing of_node_put() in an error path.
Add missing of_node_put() to avoid refcount leak.
Fixes: a3c53be55c95 ("net: dsa: mv88e6xxx: Support multiple MDIO busses")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
changes in v2:
- Add Fixes tag.
v1 link: https://lore.kernel.org/r/20220526083748.39816-1-linmq006@gmail.com/
---
drivers/net/dsa/mv88e6xxx/chip.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 5d2c57a7c708..0726df6aeb1f 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -3960,8 +3960,10 @@ static int mv88e6xxx_mdios_register(struct mv88e6xxx_chip *chip,
*/
child = of_get_child_by_name(np, "mdio");
err = mv88e6xxx_mdio_register(chip, child, false);
- if (err)
+ if (err) {
+ of_node_put(child);
return err;
+ }
/* Walk the device tree, and see if there are any other nodes
* which say they are compatible with the external mdio
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] net: dsa: mv88e6xxx: Fix refcount leak in mv88e6xxx_mdios_register
2022-05-26 11:24 [PATCH v2] net: dsa: mv88e6xxx: Fix refcount leak in mv88e6xxx_mdios_register Miaoqian Lin
@ 2022-05-26 12:18 ` Andrew Lunn
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Lunn @ 2022-05-26 12:18 UTC (permalink / raw)
To: Miaoqian Lin
Cc: Vivien Didelot, Florian Fainelli, Vladimir Oltean,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
netdev, linux-kernel
On Thu, May 26, 2022 at 03:24:15PM +0400, Miaoqian Lin wrote:
> of_get_child_by_name() returns a node pointer with refcount
> incremented, we should use of_node_put() on it when done.
> This function missing of_node_put() in an error path.
> Add missing of_node_put() to avoid refcount leak.
What about releasing the reference on the non error case?
Where is that.
Andrew
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-05-26 12:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-26 11:24 [PATCH v2] net: dsa: mv88e6xxx: Fix refcount leak in mv88e6xxx_mdios_register Miaoqian Lin
2022-05-26 12:18 ` Andrew Lunn
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.