Skip to content

Commit

Permalink
Staging: iio/accel: Changed data type of val in store_measurement_mod…
Browse files Browse the repository at this point in the history
…e to u8

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.

Signed-off-by: Andreas Ruprecht <rupran@einserver.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Andreas Ruprecht authored and Greg Kroah-Hartman committed Nov 29, 2011
1 parent 359f9ca commit 3b724ca
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/staging/iio/accel/sca3000_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,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);
Expand Down

0 comments on commit 3b724ca

Please sign in to comment.