From: Jonathan Cameron <jic23@kernel.org>
To: Hartmut Knaack <knaack.h@gmx.de>, linux-iio@vger.kernel.org
Cc: Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald <pmeerw@pmeerw.net>,
Martin Fuzzey <mfuzzey@parkeon.com>,
Roberta Dobrescu <roberta.dobrescu@gmail.com>,
martink@posteo.de
Subject: Re: [PATCH 4/7] iio:accel:mma8452: check values to be written
Date: Sat, 8 Aug 2015 17:31:18 +0100 [thread overview]
Message-ID: <55C62ED6.3070403@kernel.org> (raw)
In-Reply-To: <35eaf1398b5b084bf611a1d5c024d98068531b93.1438483410.git.knaack.h@gmx.de>
On 02/08/15 21:43, Hartmut Knaack wrote:
> Check values to be written to the device for valid lower and upper bounds.
>
> Signed-off-by: Hartmut Knaack <knaack.h@gmx.de>
Applied. Thanks. Note these will be in testing for a short while
if anyone else wants to comment.
J
> ---
> drivers/iio/accel/mma8452.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
> index 1463392f679c..516b6108d5f8 100644
> --- a/drivers/iio/accel/mma8452.c
> +++ b/drivers/iio/accel/mma8452.c
> @@ -471,15 +471,17 @@ static int mma8452_write_thresh(struct iio_dev *indio_dev,
>
> switch (info) {
> case IIO_EV_INFO_VALUE:
> - return mma8452_change_config(data, MMA8452_TRANSIENT_THS,
> - val & MMA8452_TRANSIENT_THS_MASK);
> + if (val < 0 || val > MMA8452_TRANSIENT_THS_MASK)
> + return -EINVAL;
> +
> + return mma8452_change_config(data, MMA8452_TRANSIENT_THS, val);
>
> case IIO_EV_INFO_PERIOD:
> steps = (val * USEC_PER_SEC + val2) /
> mma8452_transient_time_step_us[
> mma8452_get_odr_index(data)];
>
> - if (steps > 0xff)
> + if (steps < 0 || steps > 0xff)
> return -EINVAL;
>
> return mma8452_change_config(data, MMA8452_TRANSIENT_COUNT,
>
next prev parent reply other threads:[~2015-08-08 16:31 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-02 20:43 [PATCH 0/7] mma8452 fixes and cleanup Hartmut Knaack
2015-08-02 20:43 ` [PATCH 1/7] iio:accel:mma8452: fix _get_hp_filter_index Hartmut Knaack
2015-08-08 16:28 ` Jonathan Cameron
2015-08-02 20:43 ` [PATCH 2/7] iio:accel:mma8452: drop double include Hartmut Knaack
2015-08-08 16:28 ` Jonathan Cameron
2015-08-02 20:43 ` [PATCH 3/7] iio:accel:mma8452: pass up real error code Hartmut Knaack
2015-08-08 16:30 ` Jonathan Cameron
2015-08-02 20:43 ` [PATCH 4/7] iio:accel:mma8452: check values to be written Hartmut Knaack
2015-08-08 16:31 ` Jonathan Cameron [this message]
2015-08-02 20:43 ` [PATCH 5/7] iio:accel:mma8452: rework register definitions Hartmut Knaack
2015-08-08 16:36 ` Jonathan Cameron
2015-08-09 9:01 ` Hartmut Knaack
2015-08-02 20:43 ` [PATCH 6/7] iio:accel:mma8452: coding style cleanup Hartmut Knaack
2015-08-08 16:37 ` Jonathan Cameron
2015-08-02 20:43 ` [PATCH 7/7] iio:accel:mma8452: reorder Kconfig entry Hartmut Knaack
2015-08-08 16:38 ` 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=55C62ED6.3070403@kernel.org \
--to=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=martink@posteo.de \
--cc=mfuzzey@parkeon.com \
--cc=pmeerw@pmeerw.net \
--cc=roberta.dobrescu@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.