提交 00efcb1c 编写于 作者: S Sylwester Nawrocki 提交者: Mike Turquette

clk: Correct handling of NULL clk in __clk_{get, put}

Ensure clk->kref is dereferenced only when clk is not NULL.
Signed-off-by: NSylwester Nawrocki <s.nawrocki@samsung.com>
Tested-by: NSachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: NMike Turquette <mturquette@linaro.org>
上级 624009a7
...@@ -2226,24 +2226,25 @@ EXPORT_SYMBOL_GPL(devm_clk_unregister); ...@@ -2226,24 +2226,25 @@ EXPORT_SYMBOL_GPL(devm_clk_unregister);
*/ */
int __clk_get(struct clk *clk) int __clk_get(struct clk *clk)
{ {
if (clk && !try_module_get(clk->owner)) if (clk) {
return 0; if (!try_module_get(clk->owner))
return 0;
kref_get(&clk->ref); kref_get(&clk->ref);
}
return 1; return 1;
} }
void __clk_put(struct clk *clk) void __clk_put(struct clk *clk)
{ {
if (WARN_ON_ONCE(IS_ERR(clk))) if (!clk || WARN_ON_ONCE(IS_ERR(clk)))
return; return;
clk_prepare_lock(); clk_prepare_lock();
kref_put(&clk->ref, __clk_release); kref_put(&clk->ref, __clk_release);
clk_prepare_unlock(); clk_prepare_unlock();
if (clk) module_put(clk->owner);
module_put(clk->owner);
} }
/*** clk rate change notifiers ***/ /*** clk rate change notifiers ***/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册