From 1695854b371cdd4d17835a406675245a8dfe6cff Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Wed, 23 Dec 2020 10:00:24 +0800 Subject: [PATCH] hw/block: m25p80: Don't write to flash if write is disabled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When write is disabled, the write to flash should be avoided in flash_write8(). Fixes: 82a2499011a7 ("m25p80: Initial implementation of SPI flash device") Signed-off-by: Bin Meng Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Francisco Iglesias Message-id: 1608688825-81519-1-git-send-email-bmeng.cn@gmail.com Signed-off-by: Alistair Francis --- hw/block/m25p80.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/block/m25p80.c b/hw/block/m25p80.c index 1b3f2405a1..63278cbda5 100644 --- a/hw/block/m25p80.c +++ b/hw/block/m25p80.c @@ -601,6 +601,7 @@ void flash_write8(Flash *s, uint32_t addr, uint8_t data) if (!s->write_enable) { qemu_log_mask(LOG_GUEST_ERROR, "M25P80: write with write protect!\n"); + return; } if ((prev ^ data) & data) {