nand: fix address overflow
authorRabin Vincent <rabin.vincent@axis.com>
Tue, 10 Nov 2015 13:25:47 +0000 (14:25 +0100)
committerKevin Wolf <kwolf@redhat.com>
Wed, 18 Nov 2015 14:54:15 +0000 (15:54 +0100)
The shifts of the address mask and value shift beyond 32 bits when there
are 5 address cycles.

Cc: qemu-stable@nongnu.org
Signed-off-by: Rabin Vincent <rabin.vincent@axis.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
hw/block/nand.c

index 61d2cec032e113010e9e698f4c1e603255ea7535..a68266f88788aa4ce8c1e775c00b93e7e3f4fa5d 100644 (file)
@@ -522,8 +522,8 @@ void nand_setio(DeviceState *dev, uint32_t value)
 
     if (s->ale) {
         unsigned int shift = s->addrlen * 8;
-        unsigned int mask = ~(0xff << shift);
-        unsigned int v = value << shift;
+        uint64_t mask = ~(0xffull << shift);
+        uint64_t v = (uint64_t)value << shift;
 
         s->addr = (s->addr & mask) | v;
         s->addrlen ++;