Skip to content

Commit

Permalink
hw/display/bcm2835_fb: Silence Coverity warning about multiply overflow
Browse files Browse the repository at this point in the history
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>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 20181005133012.26490-1-peter.maydell@linaro.org
  • Loading branch information
pm215 committed Oct 8, 2018
1 parent 167765f commit 74e2e59
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion hw/display/bcm2835_fb.c
Expand Up @@ -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);
Expand Down

0 comments on commit 74e2e59

Please sign in to comment.