Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: ti: clkctrl: Fix returning uninitialized data

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: 88a172526c32 ("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>

authored by

Tony Lindgren and committed by
Stephen Boyd
41b3588d 1cc54078

+5 -2
+5 -2
drivers/clk/ti/clkctrl.c
··· 229 229 { 230 230 struct omap_clkctrl_provider *provider = data; 231 231 struct omap_clkctrl_clk *entry; 232 + bool found = false; 232 233 233 234 if (clkspec->args_count != 2) 234 235 return ERR_PTR(-EINVAL); ··· 239 238 240 239 list_for_each_entry(entry, &provider->clocks, node) { 241 240 if (entry->reg_offset == clkspec->args[0] && 242 - entry->bit_offset == clkspec->args[1]) 241 + entry->bit_offset == clkspec->args[1]) { 242 + found = true; 243 243 break; 244 + } 244 245 } 245 246 246 - if (!entry) 247 + if (!found) 247 248 return ERR_PTR(-EINVAL); 248 249 249 250 return entry->clk;