From: Jonathan Cameron <jic23@kernel.org>
To: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH][next] iio: hrtimer-trigger: Fix potential integer overflow in iio_hrtimer_store_sampling_frequency
Date: Mon, 5 Apr 2021 17:26:46 +0100 [thread overview]
Message-ID: <20210405172646.6a9f1b7d@jic23-huawei> (raw)
In-Reply-To: <20210329205817.GA188755@embeddedor>
On Mon, 29 Mar 2021 15:58:17 -0500
"Gustavo A. R. Silva" <gustavoars@kernel.org> wrote:
> Add suffix ULL to constant 1000 in order to avoid a potential integer
> overflow and give the compiler complete information about the proper
> arithmetic to use. Notice that this constant is being used in a context
> that expects an expression of type unsigned long long, but it's
> currently evaluated using 32-bit arithmetic.
>
> Addresses-Coverity-ID: 1503062 ("Unintentional integer overflow")
> Fixes: dafcf4ed8392 ("iio: hrtimer: Allow sub Hz granularity")
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Thanks, Applied to the togreg branch of iio.git and pushed out as testing
for 0-day to poke at it.
Thanks,
Jonathan
> ---
> drivers/iio/trigger/iio-trig-hrtimer.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/trigger/iio-trig-hrtimer.c b/drivers/iio/trigger/iio-trig-hrtimer.c
> index 51e362f091c2..716c795d08fb 100644
> --- a/drivers/iio/trigger/iio-trig-hrtimer.c
> +++ b/drivers/iio/trigger/iio-trig-hrtimer.c
> @@ -63,7 +63,7 @@ ssize_t iio_hrtimer_store_sampling_frequency(struct device *dev,
> if (integer < 0 || fract < 0)
> return -ERANGE;
>
> - val = fract + 1000 * integer; /* mHz */
> + val = fract + 1000ULL * integer; /* mHz */
>
> if (!val || val > UINT_MAX)
> return -EINVAL;
next prev parent reply other threads:[~2021-04-05 16:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-29 20:58 [PATCH][next] iio: hrtimer-trigger: Fix potential integer overflow in iio_hrtimer_store_sampling_frequency Gustavo A. R. Silva
2021-04-05 16:26 ` Jonathan Cameron [this message]
2021-04-06 10:13 ` Gustavo A. R. Silva
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=20210405172646.6a9f1b7d@jic23-huawei \
--to=jic23@kernel.org \
--cc=gustavoars@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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