Skip to contentSkip to conversation

clk: rockchip: Initialize hw to error to avoid undefined behavior

PATCH In review Stephen Boyd 2 participants 2 messages Sep 24, 2020

Subsystems (2)
lore
Share & tools
lore

Stephen Boyd

author maintainer
#0 lore raw

PATCH 1/1 clk: rockchip: Initialize hw to error to avoid undefined behavior

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 <[email protected]>
Cc Heiko Stuebner <[email protected]>
Fixes 956060a52795 ("clk: rockchip: add support for half divider")
---
 drivers/clk/rockchip/clk-half-divider.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/rockchip/clk-half-divider.c +1 -1
index e97fd3dfbae7..ccd5c270c213 100644
@@ -166,7 +166,7 @@ struct clk *rockchip_clk_register_halfdiv(const char *name,
 					  unsigned long flags,
 					  spinlock_t *lock)
 {
-	struct clk_hw *hw;
+	struct clk_hw *hw = ERR_PTR(-ENOMEM);
 	struct clk_mux *mux = NULL;
 	struct clk_gate *gate = NULL;
 	struct clk_divider *div = NULL;

base-commit: ca52a47af60f791b08a540a8e14d8f5751ee63e9

Signature · 1 line
https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git/
maintainer Reviewed-by on v1 1/1
#1 lore raw

Am Donnerstag, 24. September 2020, 02:44:41 CEST schrieb Stephen Boyd:

Quoted 6 lines

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:

Quoted 7 lines

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 <[email protected]>
Cc Heiko Stuebner <[email protected]>
Fixes 956060a52795 ("clk: rockchip: add support for half divider")
Quoted 20 lines
---
 drivers/clk/rockchip/clk-half-divider.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/rockchip/clk-half-divider.c +1 -1
index e97fd3dfbae7..ccd5c270c213 100644
@@ -166,7 +166,7 @@ struct clk *rockchip_clk_register_halfdiv(const char *name,
 					  unsigned long flags,
 					  spinlock_t *lock)
 {
-	struct clk_hw *hw;
+	struct clk_hw *hw = ERR_PTR(-ENOMEM);
 	struct clk_mux *mux = NULL;
 	struct clk_gate *gate = NULL;
 	struct clk_divider *div = NULL;

base-commit: ca52a47af60f791b08a540a8e14d8f5751ee63e9