stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] lib/genalloc: fix device leak in of_gen_pool_get()
@ 2025-09-24  8:02 Johan Hovold
  0 siblings, 0 replies; only message in thread
From: Johan Hovold @ 2025-09-24  8:02 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, Johan Hovold, stable, Philipp Zabel

Make sure to drop the reference taken when looking up the genpool
platform device in of_gen_pool_get() before returning the pool.

Note that holding a reference to a device does typically not prevent its
devres managed resources from being released so there is no point in
keeping the reference.

Fixes: 9375db07adea ("genalloc: add devres support, allow to find a managed pool by device")
Cc: stable@vger.kernel.org	# 3.10
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 lib/genalloc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/genalloc.c b/lib/genalloc.c
index 4fa5635bf81b..841f29783833 100644
--- a/lib/genalloc.c
+++ b/lib/genalloc.c
@@ -899,8 +899,11 @@ struct gen_pool *of_gen_pool_get(struct device_node *np,
 		if (!name)
 			name = of_node_full_name(np_pool);
 	}
-	if (pdev)
+	if (pdev) {
 		pool = gen_pool_get(&pdev->dev, name);
+		put_device(&pdev->dev);
+	}
+
 	of_node_put(np_pool);
 
 	return pool;
-- 
2.49.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2025-09-24  8:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-24  8:02 [PATCH] lib/genalloc: fix device leak in of_gen_pool_get() Johan Hovold

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).