linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin Kepplinger <martink@posteo.de>
To: jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Martin Kepplinger <martink@posteo.de>
Subject: [PATCH] iio: accel: mma9551_core: prevent using uninitialized variable
Date: Mon, 10 Dec 2018 15:25:32 +0100	[thread overview]
Message-ID: <20181210142532.15315-1-martink@posteo.de> (raw)

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


             reply	other threads:[~2018-12-10 14:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-10 14:25 Martin Kepplinger [this message]
2018-12-10 21:18 ` [PATCH] iio: accel: mma9551_core: prevent using uninitialized variable Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181210142532.15315-1-martink@posteo.de \
    --to=martink@posteo.de \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).