]> xenbits.xensource.com Git - qemu-upstream-4.6-testing.git/commitdiff
hw/arm/omap_gpmc: Avoid buffer overrun filling prefetch FIFO
authorPeter Maydell <peter.maydell@linaro.org>
Tue, 13 May 2014 15:09:39 +0000 (16:09 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Tue, 13 May 2014 15:09:39 +0000 (16:09 +0100)
In fill_prefetch_fifo(), if the device we are reading from is 16 bit,
then we must not try to transfer an odd number of bytes into the FIFO.
This could otherwise have resulted in our overrunning the prefetch.fifo
array by one byte.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
hw/misc/omap_gpmc.c

index 20472741230f589f4e9b01f497664a2969869848..cddea241d45fa0d1c7344dbd623c2c297d446479 100644 (file)
@@ -242,6 +242,10 @@ static void fill_prefetch_fifo(struct omap_gpmc_s *s)
     if (bytes > s->prefetch.count) {
         bytes = s->prefetch.count;
     }
+    if (is16bit) {
+        bytes &= ~1;
+    }
+
     s->prefetch.count -= bytes;
     s->prefetch.fifopointer += bytes;
     fptr = 64 - s->prefetch.fifopointer;