Skip to content

Commit

Permalink
staging: iio: add check for measurement configuration value passed to…
Browse files Browse the repository at this point in the history
… 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>
  • Loading branch information
Peter Meerwald authored and Greg Kroah-Hartman committed May 17, 2012
1 parent 13f6eb6 commit e278df1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/staging/iio/magnetometer/hmc5843.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e278df1

Please sign in to comment.