diff options
author | Tomeu Vizoso <tomeu.vizoso@collabora.com> | 2014-12-02 02:54:19 -0500 |
---|---|---|
committer | Michael Turquette <mturquette@linaro.org> | 2014-12-03 18:15:34 -0500 |
commit | 10cdfe54dab034311c8e2fad9ba2dffbe616caa9 (patch) | |
tree | 9a475d10896be0745db097ff414dec7447466f9c | |
parent | 4afbe1760d89fec07e7a8cce58beb1b4921a194c (diff) |
clk: Don't try to use a struct clk* after it could have been freed
As __clk_release could call kfree on clk and then we wouldn't have a safe way
of getting the module that owns the clock.
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Fixes: fcb0ee6a3d33 ("clk: Implement clk_unregister")
Reviewed-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Michael Turquette <mturquette@linaro.org>
-rw-r--r-- | drivers/clk/clk.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 42f940ff5edf..609e9db1a69a 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c | |||
@@ -2268,14 +2268,17 @@ int __clk_get(struct clk *clk) | |||
2268 | 2268 | ||
2269 | void __clk_put(struct clk *clk) | 2269 | void __clk_put(struct clk *clk) |
2270 | { | 2270 | { |
2271 | struct module *owner; | ||
2272 | |||
2271 | if (!clk || WARN_ON_ONCE(IS_ERR(clk))) | 2273 | if (!clk || WARN_ON_ONCE(IS_ERR(clk))) |
2272 | return; | 2274 | return; |
2273 | 2275 | ||
2274 | clk_prepare_lock(); | 2276 | clk_prepare_lock(); |
2277 | owner = clk->owner; | ||
2275 | kref_put(&clk->ref, __clk_release); | 2278 | kref_put(&clk->ref, __clk_release); |
2276 | clk_prepare_unlock(); | 2279 | clk_prepare_unlock(); |
2277 | 2280 | ||
2278 | module_put(clk->owner); | 2281 | module_put(owner); |
2279 | } | 2282 | } |
2280 | 2283 | ||
2281 | /*** clk rate change notifiers ***/ | 2284 | /*** clk rate change notifiers ***/ |