Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: sunxi: fix uninitialized access

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>

authored by

Arnd Bergmann and committed by
Stephen Boyd
4e903450 2c606871

+4
+4
drivers/clk/sunxi/clk-sun8i-bus-gates.c
··· 78 78 clk_parent = APB1; 79 79 else if (index >= 96 && index <= 127) 80 80 clk_parent = APB2; 81 + else { 82 + WARN_ON(true); 83 + continue; 84 + } 81 85 82 86 clk_reg = reg + 4 * (index / 32); 83 87 clk_bit = index % 32;