public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4 RESEND] mfd: arizona: fix undefined behavior
@ 2019-05-20  9:06 Charles Keepax
  2019-05-20  9:06 ` [PATCH 2/4 RESEND] mfd: madera: Fix bad reference to pinctrl.txt file Charles Keepax
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Charles Keepax @ 2019-05-20  9:06 UTC (permalink / raw)
  To: lee.jones; +Cc: arnd, natechancellor, ottosabart, linux-kernel, patches

From: Arnd Bergmann <arnd@arndb.de>

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>
---
 drivers/mfd/arizona-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index 27b61639cdc7e..0ca0fc9a67fd9 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -996,7 +996,7 @@ int arizona_dev_init(struct arizona *arizona)
 	unsigned int reg, val;
 	int (*apply_patch)(struct arizona *) = NULL;
 	const struct mfd_cell *subdevs = NULL;
-	int n_subdevs, ret, i;
+	int n_subdevs = 0, ret, i;
 
 	dev_set_drvdata(arizona->dev, arizona);
 	mutex_init(&arizona->clk_lock);
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-06-12  8:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-20  9:06 [PATCH 1/4 RESEND] mfd: arizona: fix undefined behavior Charles Keepax
2019-05-20  9:06 ` [PATCH 2/4 RESEND] mfd: madera: Fix bad reference to pinctrl.txt file Charles Keepax
2019-05-27 13:52   ` Mauro Carvalho Chehab
2019-06-12  8:31   ` Lee Jones
2019-05-20  9:06 ` [PATCH 3/4] mfd: madera: Fix potential uninitialised use of variable Charles Keepax
2019-06-12  8:31   ` Lee Jones
2019-05-20  9:06 ` [PATCH 4/4] mfd: madera: Add supply mapping for MICVDD Charles Keepax
2019-06-12  8:32   ` Lee Jones
2019-06-12  8:31 ` [PATCH 1/4 RESEND] mfd: arizona: fix undefined behavior Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox