From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:54070) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGs7q-00080F-2U for qemu-devel@nongnu.org; Thu, 20 Oct 2011 08:53:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RGs7f-0003jt-C4 for qemu-devel@nongnu.org; Thu, 20 Oct 2011 08:53:33 -0400 Received: from smtp.nokia.com ([147.243.128.24]:59249 helo=mgw-da01.nokia.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RGs7f-0003jS-6N for qemu-devel@nongnu.org; Thu, 20 Oct 2011 08:53:23 -0400 Received: from Ziltoidia.research.nokia.com (esdhcp034185.research.nokia.com [172.21.34.185]) by mgw-da01.nokia.com (Switch-3.4.4/Switch-3.4.4) with ESMTP id p9KCrH7X001248 for ; Thu, 20 Oct 2011 15:53:19 +0300 From: juha.riihimaki@nokia.com Date: Thu, 20 Oct 2011 15:53:35 +0300 Message-Id: <1319115215-21224-3-git-send-email-juha.riihimaki@nokia.com> In-Reply-To: <1319115215-21224-1-git-send-email-juha.riihimaki@nokia.com> References: <1319115215-21224-1-git-send-email-juha.riihimaki@nokia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v2 2/2] hw/onenand: reject read-only drives List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org From: Juha Riihim=C3=A4ki Signed-off-by: Juha Riihim=C3=A4ki --- hw/onenand.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) 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" =20 /* 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 =3D 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 =3D s->bdrv; } s->otp =3D memset(g_malloc((64 + 2) << PAGE_SHIFT), --=20 1.7.5.4