]> git.hungrycats.org Git - linux/commit
clk: Fix memory leak in devm_clk_notifier_register()
authorFei Shao <fshao@chromium.org>
Mon, 19 Jun 2023 03:22:53 +0000 (11:22 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 11 Jul 2023 17:39:44 +0000 (19:39 +0200)
commitcb1b04fd4283fc8f9acefe0ddc61ba072ed44877
tree3ddff54c78a1bd09cd2e1068b1b913b84863ea45
parent225a9c1047e7bf2654a27f86003637770c7ba988
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>
drivers/clk/clk.c