Received: from [140.186.70.92] (port=55359 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ov8NA-0000HP-FJ for qemu-devel@nongnu.org; Mon, 13 Sep 2010 08:43:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Ov8N6-0004Mc-AA for qemu-devel@nongnu.org; Mon, 13 Sep 2010 08:43:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51350) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ov8N6-0004MW-2v for qemu-devel@nongnu.org; Mon, 13 Sep 2010 08:42:56 -0400 From: Kevin Wolf Date: Mon, 13 Sep 2010 14:42:49 +0200 Message-Id: <1284381771-7333-12-git-send-email-kwolf@redhat.com> In-Reply-To: <1284381771-7333-1-git-send-email-kwolf@redhat.com> References: <1284381771-7333-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [STABLE 0.13][PATCH 11/13] 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: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: 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 (cherry picked from commit bfd0049440f53745d31eb93c208f0f3ab6308027) --- 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.7.2.2