Skip to content

Commit

Permalink
Staging: iio/accel: Added a range check for val in store_measurement_…
Browse files Browse the repository at this point in the history
…mode()

In sca3000_store_measurement_mode() we use val to and it with a mask.
This mask is only two bits long (as we are only interested in the
lowest two bits), so a value bigger than 3 was silently ignored so
far.

Now this function will return -EINVAL, if val is bigger than 3.

Signed-off-by: Andreas Ruprecht <rupran@einserver.de>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Andreas Ruprecht authored and Greg Kroah-Hartman committed Dec 8, 2011
1 parent bba4277 commit d666c0d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/staging/iio/accel/sca3000_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,10 @@ sca3000_store_measurement_mode(struct device *dev,
ret = kstrtou8(buf, 10, &val);
if (ret)
goto error_ret;
if (val > 3) {
ret = -EINVAL;
goto error_ret;
}
ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_MODE, 1);
if (ret)
goto error_ret;
Expand Down

0 comments on commit d666c0d

Please sign in to comment.