From a3efecb847dd89886f7cd3f71661b2d79ec68072 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juha=20Riihim=C3=A4ki?= Date: Thu, 20 Oct 2011 14:53:35 +0200 Subject: hw/onenand: reject read-only drives MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Juha Riihimäki Reviewed-by: Markus Armbruster Signed-off-by: Andrzej Zaborowski --- hw/onenand.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'hw/onenand.c') diff --git a/hw/onenand.c b/hw/onenand.c index 6f68f70698..7898da9321 100644 --- a/hw/onenand.c +++ b/hw/onenand.c @@ -26,6 +26,7 @@ #include "memory.h" #include "exec-memory.h" #include "sysbus.h" +#include "qemu-error.h" /* 11 for 2kB-page OneNAND ("2nd generation") and 10 for 1kB-page chips */ #define PAGE_SHIFT 11 @@ -772,6 +773,10 @@ static int onenand_initfn(SysBusDevice *dev) s->image = memset(g_malloc(size + (size >> 5)), 0xff, size + (size >> 5)); } else { + if (bdrv_is_read_only(s->bdrv)) { + error_report("Can't use a read-only drive"); + return -1; + } s->bdrv_cur = s->bdrv; } s->otp = memset(g_malloc((64 + 2) << PAGE_SHIFT), -- cgit v1.2.3