From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=49743 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PzoEt-0004aj-SU for qemu-devel@nongnu.org; Wed, 16 Mar 2011 06:46:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PzoEs-0002QY-L4 for qemu-devel@nongnu.org; Wed, 16 Mar 2011 06:46:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:22192) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PzoEs-0002QT-BZ for qemu-devel@nongnu.org; Wed, 16 Mar 2011 06:46:02 -0400 From: Kevin Wolf Date: Wed, 16 Mar 2011 11:47:57 +0100 Message-Id: <1300272481-8744-6-git-send-email-kwolf@redhat.com> In-Reply-To: <1300272481-8744-1-git-send-email-kwolf@redhat.com> References: <1300272481-8744-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 5/9] Don't allow multiwrites against a block device without underlying medium 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: Ryan Harper If the block device has been closed, we no longer have a medium to submit IO against, check for this before submitting io. This prevents a segfault further in the code where we dereference elements of the block driver. Signed-off-by: Ryan Harper Reviewed-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- block.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/block.c b/block.c index 0559d83..c8e2f97 100644 --- a/block.c +++ b/block.c @@ -2398,6 +2398,14 @@ int bdrv_aio_multiwrite(BlockDriverState *bs, BlockRequest *reqs, int num_reqs) MultiwriteCB *mcb; int i; + /* don't submit writes if we don't have a medium */ + if (bs->drv == NULL) { + for (i = 0; i < num_reqs; i++) { + reqs[i].error = -ENOMEDIUM; + } + return -1; + } + if (num_reqs == 0) { return 0; } -- 1.7.2.3