From a184e74f24f83935c8fc7cd76c06ad0717f89fdb Mon Sep 17 00:00:00 2001 From: Rabin Vincent Date: Tue, 10 Nov 2015 14:25:47 +0100 Subject: [PATCH] nand: fix address overflow 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 Reviewed-by: Paolo Bonzini Reviewed-by: Peter Crosthwaite Signed-off-by: Kevin Wolf --- hw/block/nand.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/block/nand.c b/hw/block/nand.c index 61d2cec032..a68266f887 100644 --- a/hw/block/nand.c +++ b/hw/block/nand.c @@ -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 ++;