From patchwork Fri Sep 10 10:27:02 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 64370 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9D67FB7102 for ; Fri, 10 Sep 2010 20:28:50 +1000 (EST) Received: from localhost ([127.0.0.1]:53969 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ou0qc-0002qg-P0 for incoming@patchwork.ozlabs.org; Fri, 10 Sep 2010 06:28:46 -0400 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 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; t=1284114431; l=853; s=domk; d=kevin-wolf.de; h=References:In-Reply-To:Date:Subject:Cc:To:From:X-RZG-CLASS-ID: X-RZG-AUTH; bh=xPHf4yT8Nrd2n5INchPe9EeHJZ4=; b=EkKSVRtS9yOZz/0xo7U/tj3A6TlyHWWNkx2FAjX2+wwlXicgSYmzWVC0TS5spoeafbk /Z6vLBnltjNF475wSdV8dM7aMqlhpIg7aI1mi4TZVy4IX245d/qZx3wY/1FhuFZSYnEyf ZDZbKDpuNi9O8bQgG83nJ5PPet7EAhhyltU= X-RZG-AUTH: :IW0NeWCjfulXIi4BrEKXhgYy2jE0QmIac4DjsXgwMU4hx49MjW4BbKOvd+vs6JN7Zw== X-RZG-CLASS-ID: mo00 Received: from localhost.localdomain (pD9E4C0A3.dip.t-dialin.net [217.228.192.163]) by post.strato.de (mrclete mo46) (RZmta 23.5) with ESMTP id D041a0m8AA9Qn1 ; Fri, 10 Sep 2010 12:27:11 +0200 (MEST) From: Kevin Wolf To: qemu-devel@nongnu.org Date: Fri, 10 Sep 2010 12:27:02 +0200 Message-Id: <1284114424-11960-2-git-send-email-mail@kevin-wolf.de> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1284114424-11960-1-git-send-email-mail@kevin-wolf.de> References: <1284114424-11960-1-git-send-email-mail@kevin-wolf.de> X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) Cc: Kevin Wolf Subject: [Qemu-devel] [PATCH 1/3] vvfat: Fix segfault on write to read-only disk X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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); /*