From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47365) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XW21u-0005iG-Kz for qemu-devel@nongnu.org; Mon, 22 Sep 2014 07:43:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XW21o-0007q0-UK for qemu-devel@nongnu.org; Mon, 22 Sep 2014 07:43:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39697) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XW21o-0007nx-MW for qemu-devel@nongnu.org; Mon, 22 Sep 2014 07:43:36 -0400 From: Stefan Hajnoczi Date: Mon, 22 Sep 2014 12:41:49 +0100 Message-Id: <1411386150-24003-19-git-send-email-stefanha@redhat.com> In-Reply-To: <1411386150-24003-1-git-send-email-stefanha@redhat.com> References: <1411386150-24003-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PULL v2 18/59] quorum: fix quorum_aio_cancel() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Maydell , Fam Zheng , Benoit Canet , Stefan Hajnoczi , Liu Yuan From: Liu Yuan For a fifo read pattern, we only have one running aio (possible other cases that has less number than num_children in the future), so we need to check if .acb is NULL against bdrv_aio_cancel() to avoid segfault. Cc: Eric Blake Cc: Benoit Canet Cc: Kevin Wolf Cc: Stefan Hajnoczi Signed-off-by: Liu Yuan Signed-off-by: Fam Zheng Signed-off-by: Stefan Hajnoczi --- block/quorum.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block/quorum.c b/block/quorum.c index 093382e..41c4249 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -138,7 +138,9 @@ static void quorum_aio_cancel(BlockDriverAIOCB *blockacb) /* cancel all callbacks */ for (i = 0; i < s->num_children; i++) { - bdrv_aio_cancel(acb->qcrs[i].aiocb); + if (acb->qcrs[i].aiocb) { + bdrv_aio_cancel(acb->qcrs[i].aiocb); + } } g_free(acb->qcrs); -- 1.9.3