Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 50d4b306 authored by Dan Carpenter's avatar Dan Carpenter Committed by Jonathan Cameron
Browse files

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: default avatarDan Carpenter <dan.carpenter@oracle.com>
Acked-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 95d1c8c7
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -647,6 +647,8 @@ static ssize_t ad7192_write_frequency(struct device *dev,
	ret = strict_strtoul(buf, 10, &lval);
	if (ret)
		return ret;
	if (lval == 0)
		return -EINVAL;

	mutex_lock(&indio_dev->mlock);
	if (iio_buffer_enabled(indio_dev)) {
+2 −0
Original line number Diff line number Diff line
@@ -195,6 +195,8 @@ static ssize_t adis16260_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);
	if (spi_get_device_id(st->us)) {
+2 −0
Original line number Diff line number Diff line
@@ -234,6 +234,8 @@ static ssize_t adis16400_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);

+2 −0
Original line number Diff line number Diff line
@@ -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);

+2 −0
Original line number Diff line number Diff line
@@ -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);

Loading