]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
clk: rockchip: Initialize hw to error to avoid undefined behavior
authorStephen Boyd <sboyd@kernel.org>
Thu, 24 Sep 2020 00:41:44 +0000 (17:41 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 Oct 2020 09:11:55 +0000 (10:11 +0100)
[ Upstream commit b608f11d49ec671739604cc763248d8e8fadbbeb ]

We can get down to this return value from ERR_CAST() without
initializing hw. Set it to -ENOMEM so that we always return something
sane.

Fixes the following smatch warning:

drivers/clk/rockchip/clk-half-divider.c:228 rockchip_clk_register_halfdiv() error: uninitialized symbol 'hw'.
drivers/clk/rockchip/clk-half-divider.c:228 rockchip_clk_register_halfdiv() warn: passing zero to 'ERR_CAST'

Cc: Elaine Zhang <zhangqing@rock-chips.com>
Cc: Heiko Stuebner <heiko@sntech.de>
Fixes: 956060a52795 ("clk: rockchip: add support for half divider")
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/clk/rockchip/clk-half-divider.c

index b333fc28c94b6c517a42f814e89f3e539bc762a7..37c858d689e0dba04c58ff08e3a225e9b0d3fa56 100644 (file)
@@ -166,7 +166,7 @@ struct clk *rockchip_clk_register_halfdiv(const char *name,
                                          unsigned long flags,
                                          spinlock_t *lock)
 {
-       struct clk *clk;
+       struct clk *clk = ERR_PTR(-ENOMEM);
        struct clk_mux *mux = NULL;
        struct clk_gate *gate = NULL;
        struct clk_divider *div = NULL;