Skip to contentSkip to conversation

lib-genalloc-fix-device-leak-in-of_gen_pool_get.patch removed from -mm tree

merged mm-nonmm-stable Andrew Morton 1 participant 1 message Sep 28, 2025 Stable branch

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: lib/genalloc: fix device leak in of_gen_pool_get()
has been removed from the -mm tree. Its filename was
lib-genalloc-fix-device-leak-in-of_gen_pool_get.patch

This patch was dropped because it was merged into the mm-nonmm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Johan Hovold <[email protected]>
Subject: lib/genalloc: fix device leak in of_gen_pool_get()
Date: Wed, 24 Sep 2025 10:02:07 +0200

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 Philipp Zabel <[email protected]>
Cc Vladimir Zapolskiy <[email protected]>
Cc <[email protected]> [3.10+]

---

 lib/genalloc.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
lib/genalloc.c renamed from lib/genalloc.c~lib-genalloc-fix-device-leak-in-of_gen_pool_get +4 -1
@@ -899,8 +899,11 @@ struct gen_pool *of_gen_pool_get(struct
 		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;

_

Patches currently in -mm which might be from [email protected] are