From: Kevin Wolf Date: Fri, 10 Sep 2010 10:27:02 +0000 (+0200) Subject: vvfat: Fix segfault on write to read-only disk X-Git-Tag: v0.14.0-rc0~636^2~19 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ac48e389d073bf2c8703745eef4824fabe0427ba;p=thirdparty%2Fqemu.git vvfat: Fix segfault on write to read-only disk 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 --- diff --git a/block/vvfat.c b/block/vvfat.c index 365332aa212..5898d664b04 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); /*