diff options
author | Peter Meerwald <pmeerw@pmeerw.net> | 2012-05-17 00:28:09 (GMT) |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-05-17 15:24:55 (GMT) |
commit | e278df1c82144f796fbeb5d9148ce09d544179a4 (patch) | |
tree | bfe4f0d199371e5e39572fc6993b2cf103083fe8 /drivers/staging | |
parent | 13f6eb69b15beeeaa720293c1281a14413363876 (diff) | |
download | linux-e278df1c82144f796fbeb5d9148ce09d544179a4.tar.xz |
staging: iio: add check for measurement configuration value passed to hmc5843
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/iio/magnetometer/hmc5843.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c index cf2bab8..d25b06e 100644 --- a/drivers/staging/iio/magnetometer/hmc5843.c +++ b/drivers/staging/iio/magnetometer/hmc5843.c @@ -281,9 +281,14 @@ static ssize_t hmc5843_set_measurement_configuration(struct device *dev, struct i2c_client *client = to_i2c_client(indio_dev->dev.parent); struct hmc5843_data *data = iio_priv(indio_dev); unsigned long meas_conf = 0; - int error = kstrtoul(buf, 10, &meas_conf); + int error; + + error = kstrtoul(buf, 10, &meas_conf); if (error) return error; + if (meas_conf >= HMC5843_MEAS_CONF_NOT_USED) + return -EINVAL; + mutex_lock(&data->lock); dev_dbg(dev, "set mode to %lu\n", meas_conf); |