linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Jonathan Cameron <jic23@cam.ac.uk>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Michael Hennerich <michael.hennerich@analog.com>,
	Paul Gortmaker <paul.gortmaker@windriver.com>,
	linux-iio@vger.kernel.org, devel@driverdev.osuosl.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [patch] staging:iio: prevent divide by zero bugs
Date: Mon, 27 Aug 2012 19:01:36 +0100	[thread overview]
Message-ID: <503BB600.1070703@kernel.org> (raw)
In-Reply-To: <20120818084830.GC30592@elgon.mountain>

On 08/18/2012 09:48 AM, Dan Carpenter wrote:
> "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>
merged to fixes-togreg branch.
Thanks.

> 
> diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c
> index 4ce9e3d..e803db1 100644
> --- a/drivers/staging/iio/imu/adis16400_core.c
> +++ b/drivers/staging/iio/imu/adis16400_core.c
> @@ -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);
>  
> diff --git a/drivers/staging/iio/gyro/adis16260_core.c b/drivers/staging/iio/gyro/adis16260_core.c
> index 93aa431..eb8e9d6 100644
> --- a/drivers/staging/iio/gyro/adis16260_core.c
> +++ b/drivers/staging/iio/gyro/adis16260_core.c
> @@ -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)) {
> diff --git a/drivers/staging/iio/adc/ad7192.c b/drivers/staging/iio/adc/ad7192.c
> index 405d9a8..942b3ce 100644
> --- a/drivers/staging/iio/adc/ad7192.c
> +++ b/drivers/staging/iio/adc/ad7192.c
> @@ -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)) {
> diff --git a/drivers/staging/iio/meter/ade7759.c b/drivers/staging/iio/meter/ade7759.c
> index b3f7e0f..eb0a2a9 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);
>  
> diff --git a/drivers/staging/iio/meter/ade7753.c b/drivers/staging/iio/meter/ade7753.c
> index f04ece7..3ccff18 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 6cee28a..abb1e9c 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);
>  
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

      parent reply	other threads:[~2012-08-27 18:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-18  8:48 [patch] staging:iio: prevent divide by zero bugs Dan Carpenter
2012-08-18  9:19 ` Lars-Peter Clausen
2012-08-27 18:01 ` Jonathan Cameron [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=503BB600.1070703@kernel.org \
    --to=jic23@kernel.org \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jic23@cam.ac.uk \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=michael.hennerich@analog.com \
    --cc=paul.gortmaker@windriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).