* [Qemu-devel] [PATCH] hw/display/bcm2835_fb: Silence Coverity warning about multiply overflow
@ 2018-10-05 13:30 Peter Maydell
2018-10-05 23:22 ` Paolo Bonzini
0 siblings, 1 reply; 2+ messages in thread
From: Peter Maydell @ 2018-10-05 13:30 UTC (permalink / raw)
To: qemu-arm, qemu-devel; +Cc: patches, Paolo Bonzini
Coverity complains (CID 1395628) that the multiply in the calculation
of the framebuffer base is performed as 32x32 but then used in a
context that takes a 64-bit hwaddr. This can't actually ever
overflow the 32-bit result, because of the constraints placed on
the s->config values in bcm2835_fb_validate_config(). But we
can placate Coverity anyway, by explicitly casting one of the
inputs to a hwaddr, so the whole expression is calculated with
64-bit arithmetic.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
This is one of those cases where I was 50/50 about whether to just
mark the coverity issue as a false-positive.
hw/display/bcm2835_fb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/display/bcm2835_fb.c b/hw/display/bcm2835_fb.c
index d534d00a65f..599863e4e17 100644
--- a/hw/display/bcm2835_fb.c
+++ b/hw/display/bcm2835_fb.c
@@ -190,7 +190,7 @@ static void fb_update_display(void *opaque)
}
if (s->invalidate) {
- hwaddr base = s->config.base + xoff + yoff * src_width;
+ hwaddr base = s->config.base + xoff + (hwaddr)yoff * src_width;
framebuffer_update_memory_section(&s->fbsection, s->dma_mr,
base,
s->config.yres, src_width);
--
2.19.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH] hw/display/bcm2835_fb: Silence Coverity warning about multiply overflow
2018-10-05 13:30 [Qemu-devel] [PATCH] hw/display/bcm2835_fb: Silence Coverity warning about multiply overflow Peter Maydell
@ 2018-10-05 23:22 ` Paolo Bonzini
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2018-10-05 23:22 UTC (permalink / raw)
To: Peter Maydell, qemu-arm, qemu-devel; +Cc: patches
On 05/10/2018 15:30, Peter Maydell wrote:
> Coverity complains (CID 1395628) that the multiply in the calculation
> of the framebuffer base is performed as 32x32 but then used in a
> context that takes a 64-bit hwaddr. This can't actually ever
> overflow the 32-bit result, because of the constraints placed on
> the s->config values in bcm2835_fb_validate_config(). But we
> can placate Coverity anyway, by explicitly casting one of the
> inputs to a hwaddr, so the whole expression is calculated with
> 64-bit arithmetic.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> This is one of those cases where I was 50/50 about whether to just
> mark the coverity issue as a false-positive.
Agreed, but in the end it's not too much noise, so
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Thanks,
Paolo
> hw/display/bcm2835_fb.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/display/bcm2835_fb.c b/hw/display/bcm2835_fb.c
> index d534d00a65f..599863e4e17 100644
> --- a/hw/display/bcm2835_fb.c
> +++ b/hw/display/bcm2835_fb.c
> @@ -190,7 +190,7 @@ static void fb_update_display(void *opaque)
> }
>
> if (s->invalidate) {
> - hwaddr base = s->config.base + xoff + yoff * src_width;
> + hwaddr base = s->config.base + xoff + (hwaddr)yoff * src_width;
> framebuffer_update_memory_section(&s->fbsection, s->dma_mr,
> base,
> s->config.yres, src_width);
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-10-05 23:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-05 13:30 [Qemu-devel] [PATCH] hw/display/bcm2835_fb: Silence Coverity warning about multiply overflow Peter Maydell
2018-10-05 23:22 ` Paolo Bonzini
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).