]> git.karo-electronics.de Git - linux-beck.git/commitdiff
staging: iio: add check for measurement configuration value passed to hmc5843
authorPeter Meerwald <pmeerw@pmeerw.net>
Thu, 17 May 2012 00:28:09 +0000 (02:28 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 May 2012 15:24:55 +0000 (08:24 -0700)
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Acked-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/iio/magnetometer/hmc5843.c

index cf2bab848717026f09ac6489314a6d272bf32dbf..d25b06ef80751c07abafacafb688a3777b6e3cd8 100644 (file)
@@ -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);