Skip to content

Commit 1260cbc

Browse files
jhovoldakpm00
authored andcommitted
lib/genalloc: fix device leak in of_gen_pool_get()
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/[email protected] Fixes: 9375db0 ("genalloc: add devres support, allow to find a managed pool by device") Signed-off-by: Johan Hovold <[email protected]> Cc: Philipp Zabel <[email protected]> Cc: Vladimir Zapolskiy <[email protected]> Cc: <[email protected]> [3.10+] Signed-off-by: Andrew Morton <[email protected]>
1 parent 1daf375 commit 1260cbc

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/genalloc.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,8 +899,11 @@ struct gen_pool *of_gen_pool_get(struct device_node *np,
899899
if (!name)
900900
name = of_node_full_name(np_pool);
901901
}
902-
if (pdev)
902+
if (pdev) {
903903
pool = gen_pool_get(&pdev->dev, name);
904+
put_device(&pdev->dev);
905+
}
906+
904907
of_node_put(np_pool);
905908

906909
return pool;

0 commit comments

Comments
 (0)