diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2012-08-18 09:48:00 +0100 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2012-08-27 19:00:51 +0100 |
commit | 50d4b3062d6d4f165c76854a7644b1502836f9b9 (patch) | |
tree | be3054fcd1be653399d24583a6a219b08fdf9113 /drivers/staging/iio/meter | |
parent | 95d1c8c7e26e303ccab5b65fe0ce04f70f42ea8a (diff) |
staging:iio: prevent divide by zero bugs
"val" is used as a divisor later, so we should check for zero here to
avoid a division by zero.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/staging/iio/meter')
-rw-r--r-- | drivers/staging/iio/meter/ade7753.c | 2 | ||||
-rw-r--r-- | drivers/staging/iio/meter/ade7754.c | 2 | ||||
-rw-r--r-- | drivers/staging/iio/meter/ade7759.c | 2 |
3 files changed, 6 insertions, 0 deletions
diff --git a/drivers/staging/iio/meter/ade7753.c b/drivers/staging/iio/meter/ade7753.c index f04ece7fbc2f..3ccff189f258 100644 --- a/drivers/staging/iio/meter/ade7753.c +++ b/drivers/staging/iio/meter/ade7753.c @@ -425,6 +425,8 @@ static ssize_t ade7753_write_frequency(struct device *dev, ret = strict_strtol(buf, 10, &val); if (ret) return ret; + if (val == 0) + return -EINVAL; mutex_lock(&indio_dev->mlock); diff --git a/drivers/staging/iio/meter/ade7754.c b/drivers/staging/iio/meter/ade7754.c index 6cee28a5e877..abb1e9c8d094 100644 --- a/drivers/staging/iio/meter/ade7754.c +++ b/drivers/staging/iio/meter/ade7754.c @@ -445,6 +445,8 @@ static ssize_t ade7754_write_frequency(struct device *dev, ret = strict_strtol(buf, 10, &val); if (ret) return ret; + if (val == 0) + return -EINVAL; mutex_lock(&indio_dev->mlock); diff --git a/drivers/staging/iio/meter/ade7759.c b/drivers/staging/iio/meter/ade7759.c index b3f7e0fa9612..eb0a2a98f388 100644 --- a/drivers/staging/iio/meter/ade7759.c +++ b/drivers/staging/iio/meter/ade7759.c @@ -385,6 +385,8 @@ static ssize_t ade7759_write_frequency(struct device *dev, ret = strict_strtol(buf, 10, &val); if (ret) return ret; + if (val == 0) + return -EINVAL; mutex_lock(&indio_dev->mlock); |