OSDN Git Service

clk: sunxi: fix uninitialized access
authorArnd Bergmann <arnd@arndb.de>
Wed, 23 Aug 2017 14:39:27 +0000 (16:39 +0200)
committerStephen Boyd <sboyd@codeaurora.org>
Thu, 31 Aug 2017 05:39:49 +0000 (22:39 -0700)
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>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
drivers/clk/sunxi/clk-sun8i-bus-gates.c

index 63fdb79..bee305b 100644 (file)
@@ -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;