From: Dan Carpenter <dan.carpenter@oracle.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald <pmeerw@pmeerw.net>,
Daniel Baluta <daniel.baluta@intel.com>,
linux-iio@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch] iio: magnetometer: correct a harmless off by one check
Date: Wed, 27 May 2015 11:20:52 +0300 [thread overview]
Message-ID: <20150527082052.GA19423@mwanda> (raw)
The line before limits i to 0-3 so the existing code works fine but the
check is still off by one and >= is intended instead of >.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/iio/magnetometer/mmc35240.c b/drivers/iio/magnetometer/mmc35240.c
index aa6e25d..c71392c 100644
--- a/drivers/iio/magnetometer/mmc35240.c
+++ b/drivers/iio/magnetometer/mmc35240.c
@@ -308,7 +308,7 @@ static int mmc35240_read_raw(struct iio_dev *indio_dev,
return ret;
i = (reg & MMC35240_CTRL1_BW_MASK) >> MMC35240_CTRL1_BW_SHIFT;
- if (i < 0 || i > ARRAY_SIZE(mmc35240_samp_freq))
+ if (i < 0 || i >= ARRAY_SIZE(mmc35240_samp_freq))
return -EINVAL;
*val = mmc35240_samp_freq[i];
next reply other threads:[~2015-05-27 8:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-27 8:20 Dan Carpenter [this message]
2015-05-27 8:37 ` [patch] iio: magnetometer: correct a harmless off by one check Daniel Baluta
2015-06-01 15:56 ` 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=20150527082052.GA19423@mwanda \
--to=dan.carpenter@oracle.com \
--cc=daniel.baluta@intel.com \
--cc=jic23@kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@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