Skip to content

Commit

Permalink
hw/arm/omap_gpmc: Avoid buffer overrun filling prefetch FIFO
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
pm215 committed May 13, 2014
1 parent 1a79172 commit 89f26e6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions hw/misc/omap_gpmc.c
Expand Up @@ -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;
Expand Down

0 comments on commit 89f26e6

Please sign in to comment.