Skip to content

Commit

Permalink
clk: sunxi: fix uninitialized access
Browse files Browse the repository at this point in the history
commit 4e903450bcb9a6bc90733b981d7cb8b3c4996a0e upstream.

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: ab6e23a ("clk: sunxi: Add H3 clocks support")
Signed-off-by: Arnd Bergmann <[email protected]>
Acked-by: Maxime Ripard <[email protected]>
Signed-off-by: Stephen Boyd <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
arndb authored and gregkh committed Jul 10, 2019
1 parent bd67557 commit 05cd693
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/clk/sunxi/clk-sun8i-bus-gates.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 05cd693

Please sign in to comment.