Received: from [140.186.70.92] (port=36839 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ou0p9-0002nt-Cs for qemu-devel@nongnu.org; Fri, 10 Sep 2010 06:27:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Ou0p8-0000nD-4S for qemu-devel@nongnu.org; Fri, 10 Sep 2010 06:27:15 -0400 Received: from mo-p00-ob.rzone.de ([81.169.146.162]:57140) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ou0p7-0000mg-Pv for qemu-devel@nongnu.org; Fri, 10 Sep 2010 06:27:14 -0400 From: Kevin Wolf Date: Fri, 10 Sep 2010 12:27:02 +0200 Message-Id: <1284114424-11960-2-git-send-email-mail@kevin-wolf.de> In-Reply-To: <1284114424-11960-1-git-send-email-mail@kevin-wolf.de> References: <1284114424-11960-1-git-send-email-mail@kevin-wolf.de> Subject: [Qemu-devel] [PATCH 1/3] vvfat: Fix segfault on write to read-only disk List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf vvfat tries to set the readonly flag in its open function, but nowadays this is overwritted with the readonly=... command line option. Check in bdrv_write if the vvfat was opened read-only and return an error in this case. Without this check, vvfat tries to access the qcow bs, which is NULL without enabled write support. Signed-off-by: Kevin Wolf --- block/vvfat.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/block/vvfat.c b/block/vvfat.c index 365332a..5898d66 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -2665,6 +2665,11 @@ static int vvfat_write(BlockDriverState *bs, int64_t sector_num, DLOG(checkpoint()); + /* Check if we're operating in read-only mode */ + if (s->qcow == NULL) { + return -EACCES; + } + vvfat_close_current_file(s); /* -- 1.6.0.2