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

Configure Feed

Select the types of activity you want to include in your feed.

mfd: madera: Work around false-positive -Wininitialized warning

clang-21 warns about one uninitialized variable getting dereferenced
in madera_dev_init:

drivers/mfd/madera-core.c:739:10: error: variable 'mfd_devs' is uninitialized when used here [-Werror,-Wuninitialized]
739 | mfd_devs, n_devs,
| ^~~~~~~~
drivers/mfd/madera-core.c:459:33: note: initialize the variable 'mfd_devs' to silence this warning
459 | const struct mfd_cell *mfd_devs;
| ^
| = NULL

The code is actually correct here because n_devs is only nonzero
when mfd_devs is a valid pointer, but this is impossible for the
compiler to see reliably.

Change the logic to check for the pointer as well, to make this easier
for the compiler to follow.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20250807071932.4085458-1-arnd@kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Arnd Bergmann and committed by
Lee Jones
364752aa 99767a0c

+2 -2
+2 -2
drivers/mfd/madera-core.c
··· 456 456 struct device *dev = madera->dev; 457 457 unsigned int hwid; 458 458 int (*patch_fn)(struct madera *) = NULL; 459 - const struct mfd_cell *mfd_devs; 459 + const struct mfd_cell *mfd_devs = NULL; 460 460 int n_devs = 0; 461 461 int i, ret; 462 462 ··· 670 670 goto err_reset; 671 671 } 672 672 673 - if (!n_devs) { 673 + if (!n_devs || !mfd_devs) { 674 674 dev_err(madera->dev, "Device ID 0x%x not a %s\n", hwid, 675 675 madera->type_name); 676 676 ret = -ENODEV;