As a defense, assert if the requested address is out of the card area. Suggested-by: Peter Maydell <peter.mayd...@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org> --- hw/sd/sd.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 871c30a67f..0b606e9054 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -539,6 +539,8 @@ static void sd_response_r7_make(SDState *sd, uint8_t *response) static inline uint64_t sd_addr_to_wpnum(uint64_t addr) { + assert(addr < sd->size); + return addr >> (HWBLOCK_SHIFT + SECTOR_SHIFT + WPGROUP_SHIFT); } -- 2.21.3