From 5e37141bbb9796ef139aee902a882ca97d59b84d Mon Sep 17 00:00:00 2001 From: Vincent Palatin Date: Mon, 25 Jul 2011 16:19:05 -0700 Subject: [PATCH] sd: do not add one sector to the disk size This leads to random off-by-one error. When the size of the SD is exactly 1GB, the emulation was returning a wrong SDHC CSD descriptor. Signed-off-by: Vincent Palatin Signed-off-by: Andrzej Zaborowski --- hw/sd.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/hw/sd.c b/hw/sd.c index 219a0dd296..c2c80ab7b8 100644 --- a/hw/sd.c +++ b/hw/sd.c @@ -393,9 +393,7 @@ static void sd_reset(SDState *sd, BlockDriverState *bdrv) } else { sect = 0; } - sect <<= 9; - - size = sect + 1; + size = sect << 9; sect = (size >> (HWBLOCK_SHIFT + SECTOR_SHIFT + WPGROUP_SHIFT)) + 1;