clk: ti: clkctrl: Fix returning uninitialized data
Subsystems (2)
PATCH 1/1 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.33sysc_notifier_callnotifier_call_chainblocking_notifier_call_chaindevice_add
Let's fix this by setting a found flag only when we find a match.
--- drivers/clk/ti/clkctrl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/clk/ti/clkctrl.c +5 -2
@@ -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;
Signature · 1 line
2.21.0
Quoted 14 lines · Tony Lindgren
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 withSLAB_DEBUGenabled:Unable to handle kernel paging request at virtual address 5a5a5a5a...
clk_hw_create_clk.part.33sysc_notifier_callnotifier_call_chainblocking_notifier_call_chaindevice_addLet's fix this by setting a found flag only when we find a match.
Quoted 8 lines
Cc Peter Ujfalusi <[email protected]>Cc Tomi Valkeinen <[email protected]>Reported-by Tomi Valkeinen <[email protected]>Fixes 88a172526c32 ("clk: ti: add support for clkctrl clocks")Signed-off-by Tony Lindgren <[email protected]>--- drivers/clk/ti/clkctrl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
I can boot again with this fix, thanks!
Signature · 2 lines
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
Quoted 5 lines · Tony Lindgren
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 withSLAB_DEBUGenabled:Unable to handle kernel paging request at virtual address 5a5a5a5a
Quoted 8 lines
...
clk_hw_create_clk.part.33sysc_notifier_callnotifier_call_chainblocking_notifier_call_chaindevice_addLet's fix this by setting a found flag only when we find a match.
Quoted 28 lines
Cc Peter Ujfalusi <[email protected]>Cc Tomi Valkeinen <[email protected]>Reported-by Tomi Valkeinen <[email protected]>Fixes 88a172526c32 ("clk: ti: add support for clkctrl clocks")Signed-off-by Tony Lindgren <[email protected]>--- drivers/clk/ti/clkctrl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/clk/ti/clkctrl.c +2
-1@@ -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 ]) {
drivers/clk/ti/clkctrl.c static struct clk_hw *_ti_omap4_clkctrl_xlate(struct of_phandle_args *clkspec, · line 251
Quoted 10 lines
drivers/clk/ti/clkctrl.c +3
-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
Quoting Tony Lindgren (2019-05-29 23:55:57)
Quoted 12 lines
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 withSLAB_DEBUGenabled:Unable to handle kernel paging request at virtual address 5a5a5a5a...
clk_hw_create_clk.part.33sysc_notifier_callnotifier_call_chainblocking_notifier_call_chaindevice_add
Quoted 8 lines
Let's fix this by setting a found flag only when we find a match.
Cc Peter Ujfalusi <[email protected]>Cc Tomi Valkeinen <[email protected]>Reported-by Tomi Valkeinen <[email protected]>Fixes 88a172526c32 ("clk: ti: add support for clkctrl clocks")Signed-off-by Tony Lindgren <[email protected]>---
Applied to clk-fixes