summaryrefslogtreecommitdiffstats
path: root/drivers/clk/clk.c
diff options
context:
space:
mode:
authorSylwester Nawrocki <s.nawrocki@samsung.com>2014-01-07 13:03:43 +0100
committerMike Turquette <mturquette@linaro.org>2014-02-25 06:58:38 +0100
commit00efcb1c8e1c3c5e5d3ce6f0682d66402911a84f (patch)
tree7518820a5053b309a45df72f9f3f31254a6d52e9 /drivers/clk/clk.c
parentMerge branch 'clk-tegra-more-fixes-3.14' of git://nv-tegra.nvidia.com/user/pd... (diff)
downloadlinux-00efcb1c8e1c3c5e5d3ce6f0682d66402911a84f.tar.xz
linux-00efcb1c8e1c3c5e5d3ce6f0682d66402911a84f.zip
clk: Correct handling of NULL clk in __clk_{get, put}
Ensure clk->kref is dereferenced only when clk is not NULL. Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Tested-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Mike Turquette <mturquette@linaro.org>
Diffstat (limited to '')
-rw-r--r--drivers/clk/clk.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 5517944495d8..c42e608af6bb 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -2226,24 +2226,25 @@ EXPORT_SYMBOL_GPL(devm_clk_unregister);
*/
int __clk_get(struct clk *clk)
{
- if (clk && !try_module_get(clk->owner))
- return 0;
+ if (clk) {
+ if (!try_module_get(clk->owner))
+ return 0;
- kref_get(&clk->ref);
+ kref_get(&clk->ref);
+ }
return 1;
}
void __clk_put(struct clk *clk)
{
- if (WARN_ON_ONCE(IS_ERR(clk)))
+ if (!clk || WARN_ON_ONCE(IS_ERR(clk)))
return;
clk_prepare_lock();
kref_put(&clk->ref, __clk_release);
clk_prepare_unlock();
- if (clk)
- module_put(clk->owner);
+ module_put(clk->owner);
}
/*** clk rate change notifiers ***/