* [PATCH] clk: sunxi: fix uninitialized access
@ 2017-08-23 14:39 Arnd Bergmann
2017-08-24 8:50 ` Maxime Ripard
2017-08-31 17:56 ` Stephen Boyd
0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2017-08-23 14:39 UTC (permalink / raw)
To: linux-arm-kernel
gcc-8 reports an uninitialized variable access in a code path
that we would see with incorrect DTB input:
drivers/clk/sunxi/clk-sun8i-bus-gates.c: In function 'sun8i_h3_bus_gates_init':
drivers/clk/sunxi/clk-sun8i-bus-gates.c:85:27: error: 'clk_parent' may be used uninitialized in this function [-Werror=maybe-uninitialized]
This works around by skipping invalid input and printing a warning
instead if it ever happens. The problem was apparently part of the
initiali driver submission, but older compilers don't notice it.
Fixes: ab6e23a4e388 ("clk: sunxi: Add H3 clocks support")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/clk/sunxi/clk-sun8i-bus-gates.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/clk/sunxi/clk-sun8i-bus-gates.c b/drivers/clk/sunxi/clk-sun8i-bus-gates.c
index 63fdb790df29..bee305bdddbe 100644
--- a/drivers/clk/sunxi/clk-sun8i-bus-gates.c
+++ b/drivers/clk/sunxi/clk-sun8i-bus-gates.c
@@ -78,6 +78,10 @@ static void __init sun8i_h3_bus_gates_init(struct device_node *node)
clk_parent = APB1;
else if (index >= 96 && index <= 127)
clk_parent = APB2;
+ else {
+ WARN_ON(true);
+ continue;
+ }
clk_reg = reg + 4 * (index / 32);
clk_bit = index % 32;
--
2.9.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] clk: sunxi: fix uninitialized access
2017-08-23 14:39 [PATCH] clk: sunxi: fix uninitialized access Arnd Bergmann
@ 2017-08-24 8:50 ` Maxime Ripard
2017-08-31 17:56 ` Stephen Boyd
1 sibling, 0 replies; 3+ messages in thread
From: Maxime Ripard @ 2017-08-24 8:50 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Aug 23, 2017 at 04:39:27PM +0200, Arnd Bergmann wrote:
> gcc-8 reports an uninitialized variable access in a code path
> that we would see with incorrect DTB input:
>
> drivers/clk/sunxi/clk-sun8i-bus-gates.c: In function 'sun8i_h3_bus_gates_init':
> drivers/clk/sunxi/clk-sun8i-bus-gates.c:85:27: error: 'clk_parent' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>
> This works around by skipping invalid input and printing a warning
> instead if it ever happens. The problem was apparently part of the
> initiali driver submission, but older compilers don't notice it.
>
> Fixes: ab6e23a4e388 ("clk: sunxi: Add H3 clocks support")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
That's weird it stayed for that long without any compiler noticing.
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Mike, Stephen, can you pick it up as a fix? We don't have anything
else coming your way.
Thanks!
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170824/ab1db200/attachment.sig>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] clk: sunxi: fix uninitialized access
2017-08-23 14:39 [PATCH] clk: sunxi: fix uninitialized access Arnd Bergmann
2017-08-24 8:50 ` Maxime Ripard
@ 2017-08-31 17:56 ` Stephen Boyd
1 sibling, 0 replies; 3+ messages in thread
From: Stephen Boyd @ 2017-08-31 17:56 UTC (permalink / raw)
To: linux-arm-kernel
On 08/23, Arnd Bergmann wrote:
> gcc-8 reports an uninitialized variable access in a code path
> that we would see with incorrect DTB input:
>
> drivers/clk/sunxi/clk-sun8i-bus-gates.c: In function 'sun8i_h3_bus_gates_init':
> drivers/clk/sunxi/clk-sun8i-bus-gates.c:85:27: error: 'clk_parent' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>
> This works around by skipping invalid input and printing a warning
> instead if it ever happens. The problem was apparently part of the
> initiali driver submission, but older compilers don't notice it.
>
> Fixes: ab6e23a4e388 ("clk: sunxi: Add H3 clocks support")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
Applied to clk-next
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-08-31 17:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-23 14:39 [PATCH] clk: sunxi: fix uninitialized access Arnd Bergmann
2017-08-24 8:50 ` Maxime Ripard
2017-08-31 17:56 ` 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).