Skip to contentSkip to conversation

ramfb: fix overflow

PATCH New Gerd Hoffmann 1 participant 1 message Jun 26, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ramfb: fix overflow

Quoted 4 lines

CID 1393621: (OVERFLOW_BEFORE_WIDEN)
Potentially overflowing expression "stride * s->height" with type "unsigned int" (32 bits, unsigned) is evaluated using +32-bit arithmetic, and then used in a context that expects an expression of type "hwaddr" (64 bits, unsigned).

Fix by changing stride from uint32_t to hwaddr.

---
 hw/display/ramfb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/display/ramfb.c +2 -2
index 6867bce8ae..30f5c8da20 100644
@@ -36,8 +36,8 @@ static void ramfb_fw_cfg_write(void *dev, off_t offset, size_t len)
 {
     RAMFBState *s = dev;
     void *framebuffer;
-    uint32_t stride, fourcc, format;
-    hwaddr addr, length;
+    uint32_t fourcc, format;
+    hwaddr stride, addr, length;
 
     s->width  = be32_to_cpu(s->cfg.width);
     s->height = be32_to_cpu(s->cfg.height);
Signature · 1 line
2.9.3