Skip to content

Commit 35d67a0

Browse files
arndbgregkh
authored andcommitted
mfd: arizona: Fix undefined behavior
[ Upstream commit 5da6cbc ] When the driver is used with a subdevice that is disabled in the kernel configuration, clang gets a little confused about the control flow and fails to notice that n_subdevs is only uninitialized when subdevs is NULL, and we check for that, leading to a false-positive warning: drivers/mfd/arizona-core.c:1423:19: error: variable 'n_subdevs' is uninitialized when used here [-Werror,-Wuninitialized] subdevs, n_subdevs, NULL, 0, NULL); ^~~~~~~~~ drivers/mfd/arizona-core.c:999:15: note: initialize the variable 'n_subdevs' to silence this warning int n_subdevs, ret, i; ^ = 0 Ideally, we would rearrange the code to avoid all those early initializations and have an explicit exit in each disabled case, but it's much easier to chicken out and add one more initialization here to shut up the warning. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Nathan Chancellor <natechancellor@gmail.com> Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 83cf751 commit 35d67a0

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/mfd/arizona-core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ int arizona_dev_init(struct arizona *arizona)
967967
unsigned int reg, val, mask;
968968
int (*apply_patch)(struct arizona *) = NULL;
969969
const struct mfd_cell *subdevs = NULL;
970-
int n_subdevs, ret, i;
970+
int n_subdevs = 0, ret, i;
971971

972972
dev_set_drvdata(arizona->dev, arizona);
973973
mutex_init(&arizona->clk_lock);

0 commit comments

Comments
 (0)