All of lore.kernel.org
 help / color / mirror / Atom feed
From: cmd <clement.mathieudrif.etu@gmail.com>
To: "Jamin Lin" <jamin_lin@aspeedtech.com>,
	"Cédric Le Goater" <clg@kaod.org>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Steven Lee" <steven_lee@aspeedtech.com>,
	"Troy Lee" <leetroy@gmail.com>,
	"Andrew Jeffery" <andrew@codeconstruct.com.au>,
	"Joel Stanley" <joel@jms.id.au>,
	"open list:ASPEED BMCs" <qemu-arm@nongnu.org>,
	"open list:All patches CC here" <qemu-devel@nongnu.org>
Cc: "Cédric Le Goater" <clg@redhat.com>
Subject: Re: [PATCH v2 1/2] aspeed/soc: Fix possible divide by zero
Date: Tue, 25 Jun 2024 08:00:48 +0200	[thread overview]
Message-ID: <24dbb79e-cdcc-4415-befa-e6351c8f29b4@gmail.com> (raw)
In-Reply-To: <20240625015028.1382059-2-jamin_lin@aspeedtech.com>

Hi

On 25/06/2024 03:50, Jamin Lin via wrote:
> Coverity reports a possible DIVIDE_BY_ZERO issue regarding the
> "ram_size" object property. This can not happen because RAM has
> predefined valid sizes per SoC. Nevertheless, add a test to
> close the issue.
>
> Fixes: Coverity CID 1547113
> Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
> Reviewed-by: Cédric Le Goater <clg@redhat.com>
> [ clg: Rewrote commit log ]
> Signed-off-by: Cédric Le Goater <clg@redhat.com>
> ---
>   hw/arm/aspeed_ast27x0.c | 6 ++++++
>   1 file changed, 6 insertions(+)
>
> diff --git a/hw/arm/aspeed_ast27x0.c b/hw/arm/aspeed_ast27x0.c
> index b6876b4862..d14a46df6f 100644
> --- a/hw/arm/aspeed_ast27x0.c
> +++ b/hw/arm/aspeed_ast27x0.c
> @@ -211,6 +211,12 @@ static void aspeed_ram_capacity_write(void *opaque, hwaddr addr, uint64_t data,
>       ram_size = object_property_get_uint(OBJECT(&s->sdmc), "ram-size",
>                                           &error_abort);
>   
> +    if (!ram_size) {
> +        qemu_log_mask(LOG_GUEST_ERROR,
> +                      "%s: ram_size is zero",  __func__);
> +        return;
> +    }
> +
If we are sure that the error cannot happen, shouldn't we assert instead?
>       /*
>        * Emulate ddr capacity hardware behavior.
>        * If writes the data to the address which is beyond the ram size,

  reply	other threads:[~2024-06-25  6:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-25  1:50 [PATCH v2 0/2] Fix coverity issues for AST2700 Jamin Lin via
2024-06-25  1:50 ` Jamin Lin via
2024-06-25  1:50 ` [PATCH v2 1/2] aspeed/soc: Fix possible divide by zero Jamin Lin via
2024-06-25  1:50   ` Jamin Lin via
2024-06-25  6:00   ` cmd [this message]
2024-06-25  6:03     ` Cédric Le Goater
2024-06-25  6:07       ` cmd
2024-06-25  6:15         ` Jamin Lin
2024-06-25  6:37           ` Cédric Le Goater
2024-06-25  6:41             ` Jamin Lin
2024-06-25  1:50 ` [PATCH v2 2/2] aspeed/sdmc: Remove extra R_MAIN_STATUS case Jamin Lin via

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=24dbb79e-cdcc-4415-befa-e6351c8f29b4@gmail.com \
    --to=clement.mathieudrif.etu@gmail.com \
    --cc=andrew@codeconstruct.com.au \
    --cc=clg@kaod.org \
    --cc=clg@redhat.com \
    --cc=jamin_lin@aspeedtech.com \
    --cc=joel@jms.id.au \
    --cc=leetroy@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=steven_lee@aspeedtech.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.