From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: "Cédric Le Goater" <clg@kaod.org>,
qemu-devel@nongnu.org, qemu-ppc@nongnu.org
Cc: "Frédéric Barrat" <fbarrat@linux.ibm.com>,
"Nicholas Piggin" <npiggin@gmail.com>,
"Glenn Miles" <milesg@linux.vnet.ibm.com>
Subject: Re: [PATCH] ppc/pnv: Fix potential overflow in I2C model
Date: Thu, 9 Nov 2023 09:12:44 +0100 [thread overview]
Message-ID: <64852c52-88cb-4ed1-913e-0b36ff2af7c2@linaro.org> (raw)
In-Reply-To: <20231109080536.1005500-1-clg@kaod.org>
On 9/11/23 09:05, Cédric Le Goater wrote:
> Coverity warns that "i2c_bus_busy(i2c->busses[i]) << i" might overflow
> because the expression is evaluated using 32-bit arithmetic and then
> used in a context expecting a uint64_t.
>
> Fixes: Coverity CID 1523918
> Cc: Glenn Miles <milesg@linux.vnet.ibm.com>
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
> hw/ppc/pnv_i2c.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/ppc/pnv_i2c.c b/hw/ppc/pnv_i2c.c
> index f75e59e70977..ab73c59f7704 100644
> --- a/hw/ppc/pnv_i2c.c
> +++ b/hw/ppc/pnv_i2c.c
> @@ -437,7 +437,7 @@ static uint64_t pnv_i2c_xscom_read(void *opaque, hwaddr addr,
> case I2C_PORT_BUSY_REG: /* compute busy bit for each port */
> val = 0;
> for (i = 0; i < i2c->num_busses; i++) {
> - val |= i2c_bus_busy(i2c->busses[i]) << i;
> + val |= (uint64_t) i2c_bus_busy(i2c->busses[i]) << i;
Alternatively:
val = deposit64(val, i, 1, i2c_bus_busy(i2c->busses[i]));
> }
> break;
>
next prev parent reply other threads:[~2023-11-09 8:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-09 8:05 [PATCH] ppc/pnv: Fix potential overflow in I2C model Cédric Le Goater
2023-11-09 8:12 ` Philippe Mathieu-Daudé [this message]
2023-11-09 15:02 ` Peter Maydell
2023-11-09 15:54 ` Cédric Le Goater
2023-11-09 16:07 ` Peter Maydell
2023-11-09 18:51 ` Philippe Mathieu-Daudé
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=64852c52-88cb-4ed1-913e-0b36ff2af7c2@linaro.org \
--to=philmd@linaro.org \
--cc=clg@kaod.org \
--cc=fbarrat@linux.ibm.com \
--cc=milesg@linux.vnet.ibm.com \
--cc=npiggin@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.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;
as well as URLs for NNTP newsgroup(s).