From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60284) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VrVMW-0006mi-2c for qemu-devel@nongnu.org; Fri, 13 Dec 2013 11:13:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VrVMO-0005dW-SJ for qemu-devel@nongnu.org; Fri, 13 Dec 2013 11:13:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:11445) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VrVMO-0005dP-Jp for qemu-devel@nongnu.org; Fri, 13 Dec 2013 11:13:04 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rBDGD3rR003226 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 13 Dec 2013 11:13:03 -0500 Date: Fri, 13 Dec 2013 17:13:01 +0100 From: Kevin Wolf Message-ID: <20131213161301.GL3916@dhcp-200-207.str.redhat.com> References: <1386919512-24520-1-git-send-email-famz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1386919512-24520-1-git-send-email-famz@redhat.com> Subject: Re: [Qemu-devel] [PATCH] blkdebug: Use QLIST_FOREACH_SAFE to resume IO List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: qemu-devel@nongnu.org, stefanha@redhat.com Am 13.12.2013 um 08:25 hat Fam Zheng geschrieben: > Qemu-iotest 030 was broken. > > When the coroutine runs and finishes, it will remove itself from the req > list, so let's use safe version of foreach to avoid use after free. > > Signed-off-by: Fam Zheng Thanks, applied to the block branch. > diff --git a/block/blkdebug.c b/block/blkdebug.c > index 37cf028..957be2c 100644 > --- a/block/blkdebug.c > +++ b/block/blkdebug.c > @@ -594,9 +594,9 @@ static int blkdebug_debug_breakpoint(BlockDriverState *bs, const char *event, > static int blkdebug_debug_resume(BlockDriverState *bs, const char *tag) > { > BDRVBlkdebugState *s = bs->opaque; > - BlkdebugSuspendedReq *r; > + BlkdebugSuspendedReq *r, *next; > > - QLIST_FOREACH(r, &s->suspended_reqs, next) { > + QLIST_FOREACH_SAFE(r, &s->suspended_reqs, next, next) { > if (!strcmp(r->tag, tag)) { > qemu_coroutine_enter(r->co, NULL); > return 0; This hunk wasn't strictly necessary because of the return 0, but it doesn't hurt either. Kevin