summaryrefslogtreecommitdiffstats
path: root/drivers/clk/clk.c
diff options
context:
space:
mode:
authorJerome Brunet <jbrunet@baylibre.com>2017-12-19 09:33:29 +0100
committerMichael Turquette <mturquette@baylibre.com>2017-12-19 11:44:21 -0800
commit29fd2a34ef8d863e48183bd473ba57c8d7839e25 (patch)
treecabefb26c96b4a3298aab4bcb72cf94cebb068fc /drivers/clk/clk.c
parent4fbd8d194f06c8a3fd2af1ce560ddb31f7ec8323 (diff)
downloadop-kernel-dev-29fd2a34ef8d863e48183bd473ba57c8d7839e25.zip
op-kernel-dev-29fd2a34ef8d863e48183bd473ba57c8d7839e25.tar.gz
clk: check ops pointer on clock register
Nothing really prevents a provider from (trying to) register a clock without providing the clock ops structure. We do check the individual fields before using them, but not the structure pointer itself. This may have the usual nasty consequences when the pointer is dereferenced, most likely when checking one the field during the initialization. This is fixed by returning an error on clock register if the ops pointer is NULL. Signed-off-by: Jerome Brunet <jbrunet@baylibre.com> Signed-off-by: Michael Turquette <mturquette@baylibre.com> Link: lkml.kernel.org/r/20171219083329.24746-1-jbrunet@baylibre.com
Diffstat (limited to 'drivers/clk/clk.c')
-rw-r--r--drivers/clk/clk.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 647d056..e3e98ac 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -2678,7 +2678,13 @@ struct clk *clk_register(struct device *dev, struct clk_hw *hw)
ret = -ENOMEM;
goto fail_name;
}
+
+ if (WARN_ON(!hw->init->ops)) {
+ ret = -EINVAL;
+ goto fail_ops;
+ }
core->ops = hw->init->ops;
+
if (dev && pm_runtime_enabled(dev))
core->dev = dev;
if (dev && dev->driver)
@@ -2740,6 +2746,7 @@ fail_parent_names_copy:
kfree_const(core->parent_names[i]);
kfree(core->parent_names);
fail_parent_names:
+fail_ops:
kfree_const(core->name);
fail_name:
kfree(core);
OpenPOWER on IntegriCloud