From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58762) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRIxk-0007dS-EP for qemu-devel@nongnu.org; Thu, 04 Feb 2016 07:24:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aRIxh-0000AU-8R for qemu-devel@nongnu.org; Thu, 04 Feb 2016 07:24:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44507) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRIxh-0000AN-3M for qemu-devel@nongnu.org; Thu, 04 Feb 2016 07:24:37 -0500 Date: Thu, 4 Feb 2016 13:24:33 +0100 From: Kevin Wolf Message-ID: <20160204122433.GA2314@noname> References: <1454581157-9858-1-git-send-email-xiecl.fnst@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1454581157-9858-1-git-send-email-xiecl.fnst@cn.fujitsu.com> Subject: Re: [Qemu-devel] [PATCH] quorum: fix segfault when read fails in fifo mode List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Changlong Xie Cc: Alberto Garcia , qemu devel , "Dr. David Alan Gilbert" Am 04.02.2016 um 11:19 hat Changlong Xie geschrieben: > Signed-off-by: Wen Congyang > Signed-off-by: Changlong Xie > --- > block/quorum.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/block/quorum.c b/block/quorum.c > index a5ae4b8..0965277 100644 > --- a/block/quorum.c > +++ b/block/quorum.c > @@ -295,6 +295,9 @@ static void quorum_aio_cb(void *opaque, int ret) > quorum_copy_qiov(acb->qiov, &acb->qcrs[acb->child_iter].qiov); > } > acb->vote_ret = ret; > + if (ret < 0) { > + acb->child_iter--; > + } > quorum_aio_finalize(acb); > return; > } This looks semantically correct to me (but I'd like to have an Ack from Berto), but I would fix it above: We shouldn't do ++acb->child_iter in the first place if the new value is >= s->num_children. So instead of decrementing after the fact, just move the increment to inside the then branch above. Kevin