Patchwork [2/2] hw/onenand: reject read-only drives

login
register
mail settings
Submitter Juha.Riihimaki@nokia.com
Date Oct. 19, 2011, 6:55 a.m.
Message ID <1319007353-16041-3-git-send-email-juha.riihimaki@nokia.com>
Download mbox | patch
Permalink /patch/120564/
State New
Headers show

Comments

Juha.Riihimaki@nokia.com - Oct. 19, 2011, 6:55 a.m.
From: Juha Riihimäki <juha.riihimaki@nokia.com>

Signed-off-by: Juha Riihimäki <juha.riihimaki@nokia.com>
---
 hw/onenand.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

Patch

diff --git a/hw/onenand.c b/hw/onenand.c
index 6f68f70..7898da9 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),