From: Peter Maydell <peter.maydell@linaro.org>
To: "Cédric Le Goater" <clg@redhat.com>
Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org,
Andrew Jeffery <andrew@codeconstruct.com.au>,
Joel Stanley <joel@jms.id.au>, Troy Lee <leetroy@gmail.com>,
Jamin Lin <jamin_lin@aspeedtech.com>,
Alistair Francis <alistair@alistair23.me>
Subject: Re: [PATCH] aspeed/smc: Fix possible integer overflow
Date: Fri, 12 Jul 2024 17:39:44 +0100 [thread overview]
Message-ID: <CAFEAcA8_UVRG5ihnSPzzA=hVmkqOO+ifOzrfECm07ebp3gU9Og@mail.gmail.com> (raw)
In-Reply-To: <20240712163619.1734214-1-clg@redhat.com>
On Fri, 12 Jul 2024 at 17:36, Cédric Le Goater <clg@redhat.com> wrote:
>
> Coverity reports a possible integer overflow because routine
> aspeeed_smc_hclk_divisor() has a codepath returning 0, which could
> lead to an integer overflow when computing variable 'hclk_shift' in
> the caller aspeed_smc_dma_calibration().
>
> The value passed to aspeed_smc_hclk_divisor() is always between 0 and
> 15 and, in this case, there is always a matching hclk divisor. Remove
> the return 0 and use g_assert_not_reached() instead.
>
> Fixes: Coverity CID 1547822
> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Cédric Le Goater <clg@redhat.com>
> ---
> hw/ssi/aspeed_smc.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c
> index b79815c2b8aa..7fd63669c10e 100644
> --- a/hw/ssi/aspeed_smc.c
> +++ b/hw/ssi/aspeed_smc.c
> @@ -842,8 +842,7 @@ static uint8_t aspeed_smc_hclk_divisor(uint8_t hclk_mask)
> }
> }
>
> - aspeed_smc_error("invalid HCLK mask %x", hclk_mask);
> - return 0;
> + g_assert_not_reached();
> }
>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
thanks
-- PMM
next prev parent reply other threads:[~2024-07-12 16:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-12 16:36 [PATCH] aspeed/smc: Fix possible integer overflow Cédric Le Goater
2024-07-12 16:39 ` Peter Maydell [this message]
2024-07-18 16:19 ` Cédric Le Goater
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='CAFEAcA8_UVRG5ihnSPzzA=hVmkqOO+ifOzrfECm07ebp3gU9Og@mail.gmail.com' \
--to=peter.maydell@linaro.org \
--cc=alistair@alistair23.me \
--cc=andrew@codeconstruct.com.au \
--cc=clg@redhat.com \
--cc=jamin_lin@aspeedtech.com \
--cc=joel@jms.id.au \
--cc=leetroy@gmail.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@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).