linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Andreas Ruprecht <rupran@einserver.de>
Cc: devel@linuxdriverproject.org, dan.carpenter@oracle.com,
	gregkh@suse.de, jic23@cam.ac.uk, linux-iio@vger.kernel.org
Subject: Re: [PATCH 3/3] Staging: iio/accel: Changed data type of val in store_measurement_mode to u8
Date: Thu, 01 Dec 2011 21:13:40 +0000	[thread overview]
Message-ID: <4ED7EE04.3010308@kernel.org> (raw)
In-Reply-To: <1322432262-16533-3-git-send-email-rupran@einserver.de>

On 11/27/2011 10:17 PM, Andreas Ruprecht wrote:
> The code in sca3000_store_measurement_mode() uses the variable val to
> do bitwise operations with an int mask and or-s it into st->rx[0] which
> is an entry in a u8 array (see sca3000.h).
> 
> This means up to now values larger than a u8 were silently ignored and
> just the lower 8 bits counted into the value that was written into
> st->rx[0]. This code will return -ERANGE if the value in buf was too
> large to fit into a u8.
Equal arguement holds for the mask being a u8 and for that matter we
should also verify the range is 0-3.

Do both of them and feel free to add Acked-by: Jonathan Cameron
<jic23@kernel.org>

When you get down to it this whole interface is horribly non standard
and will need cleaning up at some point.  Not that it is relevant to
this patch!

Thanks,

Jonathan

> 
> Signed-off-by: Andreas Ruprecht <rupran@einserver.de>
> ---
>  drivers/staging/iio/accel/sca3000_core.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c
> index a44a705..c3f1f6a 100644
> --- a/drivers/staging/iio/accel/sca3000_core.c
> +++ b/drivers/staging/iio/accel/sca3000_core.c
> @@ -382,10 +382,10 @@ sca3000_store_measurement_mode(struct device *dev,
>  	struct sca3000_state *st = iio_priv(indio_dev);
>  	int ret;
>  	int mask = 0x03;
> -	long val;
> +	u8 val;
>  
>  	mutex_lock(&st->lock);
> -	ret = strict_strtol(buf, 10, &val);
> +	ret = kstrtou8(buf, 10, &val);
>  	if (ret)
>  		goto error_ret;
>  	ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_MODE, 1);

  reply	other threads:[~2011-12-01 21:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20111124205657.GL3258@mwanda>
2011-11-27 22:17 ` [PATCH 1/3] Staging: iio/accel: Changed data type in adis16220_write_16bit to u16 Andreas Ruprecht
2011-11-27 22:17   ` [PATCH 2/3] Staging: iio/accel: Changed data type for val to unsigned long in write_frequency Andreas Ruprecht
2011-12-01 21:08     ` Jonathan Cameron
2011-11-27 22:17   ` [PATCH 3/3] Staging: iio/accel: Changed data type of val in store_measurement_mode to u8 Andreas Ruprecht
2011-12-01 21:13     ` Jonathan Cameron [this message]
2011-12-02 16:30       ` [PATCH 1/2] Staging: iio/accel: Changed data type of mask in store_measurement_mode() " Andreas Ruprecht
2011-12-02 16:30         ` [PATCH 2/2] Staging: iio/accel: Added a range check for val in store_measurement_mode() Andreas Ruprecht
2011-12-02 16:44       ` [PATCH 1/2] Staging: iio/accel: Changed data type of mask in store_measurement_mode() to u8 Alessandro Rubini
2011-12-02 16:56         ` [PATCH v2 " Andreas Ruprecht
2011-12-01 21:05   ` [PATCH 1/3] Staging: iio/accel: Changed data type in adis16220_write_16bit to u16 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=4ED7EE04.3010308@kernel.org \
    --to=jic23@kernel.org \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@linuxdriverproject.org \
    --cc=gregkh@suse.de \
    --cc=jic23@cam.ac.uk \
    --cc=linux-iio@vger.kernel.org \
    --cc=rupran@einserver.de \
    /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).