Skip to content

Commit 7fb933e

Browse files
Fei Shaobebarino
authored andcommitted
clk: Fix memory leak in devm_clk_notifier_register()
devm_clk_notifier_register() allocates a devres resource for clk notifier but didn't register that to the device, so the notifier didn't get unregistered on device detach and the allocated resource was leaked. Fix the issue by registering the resource through devres_add(). This issue was found with kmemleak on a Chromebook. Fixes: 6d30d50 ("clk: add devm variant of clk_notifier_register") Signed-off-by: Fei Shao <[email protected]> Link: https://lore.kernel.org/r/20230619112253.v2.1.I13f060c10549ef181603e921291bdea95f83033c@changeid Reviewed-by: Dan Carpenter <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
1 parent bd73d1f commit 7fb933e

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/clk/clk.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4695,6 +4695,7 @@ int devm_clk_notifier_register(struct device *dev, struct clk *clk,
46954695
if (!ret) {
46964696
devres->clk = clk;
46974697
devres->nb = nb;
4698+
devres_add(dev, devres);
46984699
} else {
46994700
devres_free(devres);
47004701
}

0 commit comments

Comments
 (0)