* [PATCH] clk: ti: clkctrl: Fix returning uninitialized data
@ 2019-05-30 6:55 Tony Lindgren
2019-05-31 12:04 ` Tomi Valkeinen
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Tony Lindgren @ 2019-05-30 6:55 UTC (permalink / raw)
To: Michael Turquette, Stephen Boyd, Tero Kristo
Cc: devicetree, linux-clk, linux-omap, Peter Ujfalusi, Tomi Valkeinen
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.
Cc: Peter Ujfalusi <peter.ujfalusi@ti.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
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>
---
drivers/clk/ti/clkctrl.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/clk/ti/clkctrl.c b/drivers/clk/ti/clkctrl.c
--- a/drivers/clk/ti/clkctrl.c
+++ b/drivers/clk/ti/clkctrl.c
@@ -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);
@@ -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;
--
2.21.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] clk: ti: clkctrl: Fix returning uninitialized data
2019-05-30 6:55 [PATCH] clk: ti: clkctrl: Fix returning uninitialized data Tony Lindgren
@ 2019-05-31 12:04 ` Tomi Valkeinen
2019-06-03 7:45 ` Peter Ujfalusi
2019-06-06 18:19 ` Stephen Boyd
2 siblings, 0 replies; 4+ messages in thread
From: Tomi Valkeinen @ 2019-05-31 12:04 UTC (permalink / raw)
To: Tony Lindgren, Michael Turquette, Stephen Boyd, Tero Kristo
Cc: devicetree, linux-clk, linux-omap, Peter Ujfalusi
On 30/05/2019 09:55, Tony Lindgren wrote:
> 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.
>
> Cc: Peter Ujfalusi <peter.ujfalusi@ti.com>
> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> 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>
> ---
> drivers/clk/ti/clkctrl.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
I can boot again with this fix, thanks!
Tested-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] clk: ti: clkctrl: Fix returning uninitialized data
2019-05-30 6:55 [PATCH] clk: ti: clkctrl: Fix returning uninitialized data Tony Lindgren
2019-05-31 12:04 ` Tomi Valkeinen
@ 2019-06-03 7:45 ` Peter Ujfalusi
2019-06-06 18:19 ` Stephen Boyd
2 siblings, 0 replies; 4+ messages in thread
From: Peter Ujfalusi @ 2019-06-03 7:45 UTC (permalink / raw)
To: Tony Lindgren, Michael Turquette, Stephen Boyd, Tero Kristo
Cc: devicetree, linux-clk, linux-omap, Tomi Valkeinen
On 30/05/2019 9.55, Tony Lindgren wrote:
> 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.
Tested-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
>
> Cc: Peter Ujfalusi <peter.ujfalusi@ti.com>
> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> 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>
> ---
> drivers/clk/ti/clkctrl.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/clk/ti/clkctrl.c b/drivers/clk/ti/clkctrl.c
> --- a/drivers/clk/ti/clkctrl.c
> +++ b/drivers/clk/ti/clkctrl.c
> @@ -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);
> @@ -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;
>
- Péter
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] clk: ti: clkctrl: Fix returning uninitialized data
2019-05-30 6:55 [PATCH] clk: ti: clkctrl: Fix returning uninitialized data Tony Lindgren
2019-05-31 12:04 ` Tomi Valkeinen
2019-06-03 7:45 ` Peter Ujfalusi
@ 2019-06-06 18:19 ` Stephen Boyd
2 siblings, 0 replies; 4+ messages in thread
From: Stephen Boyd @ 2019-06-06 18:19 UTC (permalink / raw)
To: Michael Turquette, Stephen Boyd, Tero Kristo, Tony Lindgren
Cc: devicetree, linux-clk, linux-omap, Peter Ujfalusi, Tomi Valkeinen
Quoting Tony Lindgren (2019-05-29 23:55:57)
> 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.
>
> Cc: Peter Ujfalusi <peter.ujfalusi@ti.com>
> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> 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>
> ---
Applied to clk-fixes
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-06-06 18:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-30 6:55 [PATCH] clk: ti: clkctrl: Fix returning uninitialized data Tony Lindgren
2019-05-31 12:04 ` Tomi Valkeinen
2019-06-03 7:45 ` Peter Ujfalusi
2019-06-06 18:19 ` Stephen Boyd
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).