summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJohan Hovold <johan@kernel.org>2025-09-24 10:02:07 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-10-19 16:21:45 +0200
commitc2b88b66bc3590fe606aefb2b7053acf7d887eea (patch)
tree90772de24252495ca498b5a46607e1c1db87aea0 /lib
parent4ce6902cc67d77547ff6cefd4d96153f35946486 (diff)
lib/genalloc: fix device leak in of_gen_pool_get()
commit 1260cbcffa608219fc9188a6cbe9c45a300ef8b5 upstream. 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. Link: https://lkml.kernel.org/r/20250924080207.18006-1-johan@kernel.org Fixes: 9375db07adea ("genalloc: add devres support, allow to find a managed pool by device") Signed-off-by: Johan Hovold <johan@kernel.org> Cc: Philipp Zabel <p.zabel@pengutronix.de> Cc: Vladimir Zapolskiy <vz@mleia.com> Cc: <stable@vger.kernel.org> [3.10+] Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/genalloc.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/genalloc.c b/lib/genalloc.c
index 9a57257988c7..bed308b4493f 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 = np_pool->name;
}
- if (pdev)
+ if (pdev) {
pool = gen_pool_get(&pdev->dev, name);
+ put_device(&pdev->dev);
+ }
+
of_node_put(np_pool);
return pool;