Skip to content

Commit

Permalink
clk: ti: clkctrl: Fix returning uninitialized data
Browse files Browse the repository at this point in the history
If we do a clk_get() for a clock that does not exists, we have
_ti_omap4_clkctrl_xlate() return uninitialized data if no match
is found. This can be seen in some cases with SLAB_DEBUG enabled:

Unable to handle kernel paging request at virtual address 5a5a5a5a
...
clk_hw_create_clk.part.33
sysc_notifier_call
notifier_call_chain
blocking_notifier_call_chain
device_add

Let's fix this by setting a found flag only when we find a match.

Reported-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Fixes: 88a1725 ("clk: ti: add support for clkctrl clocks")
Signed-off-by: Tony Lindgren <tony@atomide.com>
Tested-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Tested-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
  • Loading branch information
Tony Lindgren authored and Stephen Boyd committed Jun 6, 2019
1 parent 1cc5407 commit 41b3588
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/clk/ti/clkctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ static struct clk_hw *_ti_omap4_clkctrl_xlate(struct of_phandle_args *clkspec,
{
struct omap_clkctrl_provider *provider = data;
struct omap_clkctrl_clk *entry;
bool found = false;

if (clkspec->args_count != 2)
return ERR_PTR(-EINVAL);
Expand All @@ -238,11 +239,13 @@ static struct clk_hw *_ti_omap4_clkctrl_xlate(struct of_phandle_args *clkspec,

list_for_each_entry(entry, &provider->clocks, node) {
if (entry->reg_offset == clkspec->args[0] &&
entry->bit_offset == clkspec->args[1])
entry->bit_offset == clkspec->args[1]) {
found = true;
break;
}
}

if (!entry)
if (!found)
return ERR_PTR(-EINVAL);

return entry->clk;
Expand Down

0 comments on commit 41b3588

Please sign in to comment.