diff options
author | Fei Shao <fshao@chromium.org> | 2023-06-19 11:22:53 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-07-19 16:21:33 +0200 |
commit | 49451db71b746df990888068961f1033f7c9b734 (patch) | |
tree | 78d18bacb8e87046abee48f81dc6bf33db529c15 | |
parent | 03a705c1d7cb9c7dd55a0b96e1fc9ef7c236d35a (diff) | |
download | linux-stable-49451db71b746df990888068961f1033f7c9b734.tar.gz linux-stable-49451db71b746df990888068961f1033f7c9b734.tar.bz2 linux-stable-49451db71b746df990888068961f1033f7c9b734.zip |
clk: Fix memory leak in devm_clk_notifier_register()
[ Upstream commit 7fb933e56f77a57ef7cfc59fc34cbbf1b1fa31ff ]
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: 6d30d50d037d ("clk: add devm variant of clk_notifier_register")
Signed-off-by: Fei Shao <fshao@chromium.org>
Link: https://lore.kernel.org/r/20230619112253.v2.1.I13f060c10549ef181603e921291bdea95f83033c@changeid
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | drivers/clk/clk.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index d4a74759fe29..e0de6565800d 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -4651,6 +4651,7 @@ int devm_clk_notifier_register(struct device *dev, struct clk *clk, if (!ret) { devres->clk = clk; devres->nb = nb; + devres_add(dev, devres); } else { devres_free(devres); } |