From: Wolfram Sang <wsa@kernel.org>
To: Colin King <colin.king@canonical.com>, qii.wang@mediatek.com
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mediatek@lists.infradead.org, linux-i2c@vger.kernel.org,
Matthias Brugger <matthias.bgg@gmail.com>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH][next] i2c: mediatek: fix integer overflow on an integer multiplication
Date: Mon, 18 May 2020 16:59:28 +0000 [thread overview]
Message-ID: <20200518165928.GA5109@ninjato> (raw)
In-Reply-To: <20200518165529.57821-1-colin.king@canonical.com>
[-- Attachment #1: Type: text/plain, Size: 1344 bytes --]
On Mon, May 18, 2020 at 05:55:29PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently the calculation of sample_ns is using a 32 bit integer
> multiplication and can potentially overflow. Fix this by making the
> constant a long long to use a 64 bit multiply and hence
> avoid an overflow.
>
> Addresses-Coverity: ("Unintentional integer overflow")
> Fixes: 5f1ae73d538a ("i2c: mediatek: Add i2c ac-timing adjust support")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
CCing the patch author.
> ---
> drivers/i2c/busses/i2c-mt65xx.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c
> index 702061805925..c93492b997ce 100644
> --- a/drivers/i2c/busses/i2c-mt65xx.c
> +++ b/drivers/i2c/busses/i2c-mt65xx.c
> @@ -551,7 +551,7 @@ static int mtk_i2c_check_ac_timing(struct mtk_i2c *i2c,
> const struct i2c_spec_values *spec;
> unsigned int su_sta_cnt, low_cnt, high_cnt, max_step_cnt;
> unsigned int sda_max, sda_min, clk_ns, max_sta_cnt = 0x3f;
> - long long sample_ns = (1000000000 * (sample_cnt + 1)) / clk_src;
> + long long sample_ns = (1000000000LL * (sample_cnt + 1)) / clk_src;
>
> if (!i2c->dev_comp->timing_adjust)
> return 0;
> --
> 2.25.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: Wolfram Sang <wsa@kernel.org>
To: Colin King <colin.king@canonical.com>, qii.wang@mediatek.com
Cc: Matthias Brugger <matthias.bgg@gmail.com>,
linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org,
kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH][next] i2c: mediatek: fix integer overflow on an integer multiplication
Date: Mon, 18 May 2020 18:59:28 +0200 [thread overview]
Message-ID: <20200518165928.GA5109@ninjato> (raw)
In-Reply-To: <20200518165529.57821-1-colin.king@canonical.com>
[-- Attachment #1: Type: text/plain, Size: 1344 bytes --]
On Mon, May 18, 2020 at 05:55:29PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently the calculation of sample_ns is using a 32 bit integer
> multiplication and can potentially overflow. Fix this by making the
> constant a long long to use a 64 bit multiply and hence
> avoid an overflow.
>
> Addresses-Coverity: ("Unintentional integer overflow")
> Fixes: 5f1ae73d538a ("i2c: mediatek: Add i2c ac-timing adjust support")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
CCing the patch author.
> ---
> drivers/i2c/busses/i2c-mt65xx.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c
> index 702061805925..c93492b997ce 100644
> --- a/drivers/i2c/busses/i2c-mt65xx.c
> +++ b/drivers/i2c/busses/i2c-mt65xx.c
> @@ -551,7 +551,7 @@ static int mtk_i2c_check_ac_timing(struct mtk_i2c *i2c,
> const struct i2c_spec_values *spec;
> unsigned int su_sta_cnt, low_cnt, high_cnt, max_step_cnt;
> unsigned int sda_max, sda_min, clk_ns, max_sta_cnt = 0x3f;
> - long long sample_ns = (1000000000 * (sample_cnt + 1)) / clk_src;
> + long long sample_ns = (1000000000LL * (sample_cnt + 1)) / clk_src;
>
> if (!i2c->dev_comp->timing_adjust)
> return 0;
> --
> 2.25.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: Wolfram Sang <wsa@kernel.org>
To: Colin King <colin.king@canonical.com>, qii.wang@mediatek.com
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mediatek@lists.infradead.org, linux-i2c@vger.kernel.org,
Matthias Brugger <matthias.bgg@gmail.com>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH][next] i2c: mediatek: fix integer overflow on an integer multiplication
Date: Mon, 18 May 2020 18:59:28 +0200 [thread overview]
Message-ID: <20200518165928.GA5109@ninjato> (raw)
In-Reply-To: <20200518165529.57821-1-colin.king@canonical.com>
[-- Attachment #1.1: Type: text/plain, Size: 1344 bytes --]
On Mon, May 18, 2020 at 05:55:29PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently the calculation of sample_ns is using a 32 bit integer
> multiplication and can potentially overflow. Fix this by making the
> constant a long long to use a 64 bit multiply and hence
> avoid an overflow.
>
> Addresses-Coverity: ("Unintentional integer overflow")
> Fixes: 5f1ae73d538a ("i2c: mediatek: Add i2c ac-timing adjust support")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
CCing the patch author.
> ---
> drivers/i2c/busses/i2c-mt65xx.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c
> index 702061805925..c93492b997ce 100644
> --- a/drivers/i2c/busses/i2c-mt65xx.c
> +++ b/drivers/i2c/busses/i2c-mt65xx.c
> @@ -551,7 +551,7 @@ static int mtk_i2c_check_ac_timing(struct mtk_i2c *i2c,
> const struct i2c_spec_values *spec;
> unsigned int su_sta_cnt, low_cnt, high_cnt, max_step_cnt;
> unsigned int sda_max, sda_min, clk_ns, max_sta_cnt = 0x3f;
> - long long sample_ns = (1000000000 * (sample_cnt + 1)) / clk_src;
> + long long sample_ns = (1000000000LL * (sample_cnt + 1)) / clk_src;
>
> if (!i2c->dev_comp->timing_adjust)
> return 0;
> --
> 2.25.1
>
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
[-- Attachment #2: Type: text/plain, Size: 170 bytes --]
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek
WARNING: multiple messages have this Message-ID (diff)
From: Wolfram Sang <wsa@kernel.org>
To: Colin King <colin.king@canonical.com>, qii.wang@mediatek.com
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-mediatek@lists.infradead.org, linux-i2c@vger.kernel.org,
Matthias Brugger <matthias.bgg@gmail.com>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH][next] i2c: mediatek: fix integer overflow on an integer multiplication
Date: Mon, 18 May 2020 18:59:28 +0200 [thread overview]
Message-ID: <20200518165928.GA5109@ninjato> (raw)
In-Reply-To: <20200518165529.57821-1-colin.king@canonical.com>
[-- Attachment #1.1: Type: text/plain, Size: 1344 bytes --]
On Mon, May 18, 2020 at 05:55:29PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently the calculation of sample_ns is using a 32 bit integer
> multiplication and can potentially overflow. Fix this by making the
> constant a long long to use a 64 bit multiply and hence
> avoid an overflow.
>
> Addresses-Coverity: ("Unintentional integer overflow")
> Fixes: 5f1ae73d538a ("i2c: mediatek: Add i2c ac-timing adjust support")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
CCing the patch author.
> ---
> drivers/i2c/busses/i2c-mt65xx.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/busses/i2c-mt65xx.c b/drivers/i2c/busses/i2c-mt65xx.c
> index 702061805925..c93492b997ce 100644
> --- a/drivers/i2c/busses/i2c-mt65xx.c
> +++ b/drivers/i2c/busses/i2c-mt65xx.c
> @@ -551,7 +551,7 @@ static int mtk_i2c_check_ac_timing(struct mtk_i2c *i2c,
> const struct i2c_spec_values *spec;
> unsigned int su_sta_cnt, low_cnt, high_cnt, max_step_cnt;
> unsigned int sda_max, sda_min, clk_ns, max_sta_cnt = 0x3f;
> - long long sample_ns = (1000000000 * (sample_cnt + 1)) / clk_src;
> + long long sample_ns = (1000000000LL * (sample_cnt + 1)) / clk_src;
>
> if (!i2c->dev_comp->timing_adjust)
> return 0;
> --
> 2.25.1
>
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
[-- Attachment #2: Type: text/plain, Size: 176 bytes --]
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-05-18 16:59 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-18 16:55 [PATCH][next] i2c: mediatek: fix integer overflow on an integer multiplication Colin King
2020-05-18 16:55 ` Colin King
2020-05-18 16:55 ` Colin King
2020-05-18 16:55 ` Colin King
2020-05-18 16:59 ` Wolfram Sang [this message]
2020-05-18 16:59 ` Wolfram Sang
2020-05-18 16:59 ` Wolfram Sang
2020-05-18 16:59 ` Wolfram Sang
2020-05-18 17:11 ` Joe Perches
2020-05-18 17:11 ` Joe Perches
2020-05-18 17:11 ` Joe Perches
2020-05-18 17:11 ` Joe Perches
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=20200518165928.GA5109@ninjato \
--to=wsa@kernel.org \
--cc=colin.king@canonical.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=qii.wang@mediatek.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.