linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iio: accel: mma9551_core: prevent using uninitialized variable
@ 2018-12-10 14:25 Martin Kepplinger
  2018-12-10 21:18 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Kepplinger @ 2018-12-10 14:25 UTC (permalink / raw)
  To: jic23, knaack.h, lars, pmeerw; +Cc: linux-iio, linux-kernel, Martin Kepplinger

mma9551_gpio_config()'s switch statement sets the uninitialized pol_mask
variable but doesn't have default settings. Said function can therefore
be called in a way to use the uninitialized variable (at least in case
enum mma9551_gpio_pin is extended with unhandled values).

While things should be fine now, this initializes pol_mask just to prevent
failure.

Signed-off-by: Martin Kepplinger <martink@posteo.de>
---
 drivers/iio/accel/mma9551_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/accel/mma9551_core.c b/drivers/iio/accel/mma9551_core.c
index c34c5ce8123b..2fc79b14888b 100644
--- a/drivers/iio/accel/mma9551_core.c
+++ b/drivers/iio/accel/mma9551_core.c
@@ -539,7 +539,8 @@ EXPORT_SYMBOL(mma9551_update_config_bits);
 int mma9551_gpio_config(struct i2c_client *client, enum mma9551_gpio_pin pin,
 			u8 app_id, u8 bitnum, int polarity)
 {
-	u8 reg, pol_mask, pol_val;
+	u8 reg, pol_val;
+	u8 pol_mask = 0;
 	int ret;
 
 	if (pin > mma9551_gpio_max) {
-- 
2.11.0


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

end of thread, other threads:[~2018-12-10 21:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-10 14:25 [PATCH] iio: accel: mma9551_core: prevent using uninitialized variable Martin Kepplinger
2018-12-10 21:18 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).