From: Jonathan Cameron <jic23@kernel.org>
To: Zicheng Qu <quzicheng@huawei.com>
Cc: <Michael.Hennerich@analog.com>, <renatogeh@gmail.com>,
<lars@metafoo.de>, <giuliano.belinassi@usp.br>,
<linux-iio@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<tanghui20@huawei.com>, <zhangqiao22@huawei.com>,
<judy.chenhui@huawei.com>
Subject: Re: [PATCH] ad7780: fix division by zero in ad7780_write_raw()
Date: Thu, 31 Oct 2024 21:08:53 +0000 [thread overview]
Message-ID: <20241031210853.4a0bc3a9@jic23-huawei> (raw)
In-Reply-To: <20241028142027.1032332-1-quzicheng@huawei.com>
On Mon, 28 Oct 2024 14:20:27 +0000
Zicheng Qu <quzicheng@huawei.com> wrote:
> In the ad7780_write_raw() , val2 can be zero, which might lead to a
> division by zero error in DIV_ROUND_CLOSEST(). The ad7780_write_raw()
> is based on iio_info's write_raw. While val is explicitly declared that
> can be zero (in read mode), val2 is not specified to be non-zero.
>
> Fixes: 9085daa4abcc ("staging: iio: ad7780: add gain & filter gpio support")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Zicheng Qu <quzicheng@huawei.com>
Applied to the fixes-togreg branch of iio.git.
I might end up dragging this in to my queue for the coming merge window
if I don't get time to do another fixes pull request in the next few
days.
Jonathan
> ---
> drivers/iio/adc/ad7780.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/ad7780.c b/drivers/iio/adc/ad7780.c
> index e9b0c577c9cc..8ccb74f47030 100644
> --- a/drivers/iio/adc/ad7780.c
> +++ b/drivers/iio/adc/ad7780.c
> @@ -152,7 +152,7 @@ static int ad7780_write_raw(struct iio_dev *indio_dev,
>
> switch (m) {
> case IIO_CHAN_INFO_SCALE:
> - if (val != 0)
> + if (val != 0 || val2 == 0)
> return -EINVAL;
>
> vref = st->int_vref_mv * 1000000LL;
prev parent reply other threads:[~2024-10-31 21:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-28 14:20 [PATCH] ad7780: fix division by zero in ad7780_write_raw() Zicheng Qu
2024-10-31 13:52 ` Zicheng Qu
2024-10-31 21:08 ` 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=20241031210853.4a0bc3a9@jic23-huawei \
--to=jic23@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=giuliano.belinassi@usp.br \
--cc=judy.chenhui@huawei.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=quzicheng@huawei.com \
--cc=renatogeh@gmail.com \
--cc=tanghui20@huawei.com \
--cc=zhangqiao22@huawei.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