From patchwork Fri Oct 5 13:30:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 148179 Delivered-To: patches@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp454776lji; Fri, 5 Oct 2018 06:30:17 -0700 (PDT) X-Google-Smtp-Source: ACcGV60ICSF92+AFH/6YfudSh0CPsCjJbqOSVWqVv35UdZqmU0hCD5rl0OSrGfjp/zvX0cnv9uuT X-Received: by 2002:adf:bb02:: with SMTP id r2-v6mr8278356wrg.24.1538746217468; Fri, 05 Oct 2018 06:30:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538746217; cv=none; d=google.com; s=arc-20160816; b=zzg+L9+OPaer4stpecc2GOXZjxm7glZicZ7LlQG4VlJFJYIiPnxMom6mNo2/aOiXaU JS8ij+fS+vZCf/8Mxv5K0mr28MfURxfrR/HEVmxkl7TJSTlGE59uvpDmGzHcwmq/xRgw i9dkYBnJ0nRCju8ihf+FKe7DRsP0zHkYb1YVmfLsfNhFsG1DBpJirDPpFCQ49ZrSvqb3 FhVQOM9mG0OxZXIB4wXLUZr1HXAzmPcpv9c+BBBmji7YTSC+U+gaJ9T7nJN/fgSwcmms Ud2HxjDCW0OIDHgD0xXAL0rK7bum55ETeYffcl2bxQB5qxNdHwqpYXcd+ih2tFFJB3Hg hP3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from; bh=mvQm36icIXjN7f7xulJMaX9qZ0k3CZyoZqUdsAh8ORo=; b=jt6R8/vdxgyWDy/amUj+ubCKC/pYyayqquOvS1azDUYKJBM3mENXyGqvQC93Kg4YwJ wONeNpBIrjiTTrQzUu8FYID6RGyjWEi1LT18NMBBzDWgxUd+LfOWY2kVjIvObs3/j6re ACiA6xhd2I/dlDrxRkdvYkp7nRR2HNYcaVoJT4uGkIoedG4ipM4lVyTVln5/90CNmuo2 MhxDmhQTERSqkVR7EDuoF3OtnCzIDE76dHwQ4m4wdGZ3pBn/05z4sQkPaYAXvS5Qn2wZ c+PQS6R+A99maDCdsbHRQEu3lgwOUPv4We+vF0xKR97qyDf3XFurBHYhob5CvwrJverp oRUQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by mx.google.com with ESMTPS id m4-v6si6029342wrh.397.2018.10.05.06.30.17 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Oct 2018 06:30:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) client-ip=2001:8b0:1d0::2; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1g8QBM-0001CE-7R; Fri, 05 Oct 2018 14:30:16 +0100 From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: patches@linaro.org, Paolo Bonzini Subject: [PATCH] hw/display/bcm2835_fb: Silence Coverity warning about multiply overflow Date: Fri, 5 Oct 2018 14:30:12 +0100 Message-Id: <20181005133012.26490-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 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 --- 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(-) -- 2.19.0 Reviewed-by: Paolo Bonzini 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);