From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59631) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VrNHx-0004gW-0o for qemu-devel@nongnu.org; Fri, 13 Dec 2013 02:36:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VrNHr-0005ai-0t for qemu-devel@nongnu.org; Fri, 13 Dec 2013 02:35:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:20562) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VrNHq-0005ad-Kv for qemu-devel@nongnu.org; Fri, 13 Dec 2013 02:35:50 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rBD7ZmPp027524 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 13 Dec 2013 02:35:48 -0500 From: Fam Zheng Date: Fri, 13 Dec 2013 15:35:09 +0800 Message-Id: <1386920120-2651-2-git-send-email-famz@redhat.com> In-Reply-To: <1386920120-2651-1-git-send-email-famz@redhat.com> References: <1386920120-2651-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH v8 01/12] blkdebug: Use QLIST_FOREACH_SAFE to resume IO List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, rjones@redhat.com, armbru@redhat.com, imain@redhat.com, stefanha@redhat.com, pbonzini@redhat.com 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 --- block/blkdebug.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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; @@ -609,7 +609,7 @@ static int blkdebug_debug_remove_breakpoint(BlockDriverState *bs, const char *tag) { BDRVBlkdebugState *s = bs->opaque; - BlkdebugSuspendedReq *r; + BlkdebugSuspendedReq *r, *r_next; BlkdebugRule *rule, *next; int i, ret = -ENOENT; @@ -622,7 +622,7 @@ static int blkdebug_debug_remove_breakpoint(BlockDriverState *bs, } } } - QLIST_FOREACH(r, &s->suspended_reqs, next) { + QLIST_FOREACH_SAFE(r, &s->suspended_reqs, next, r_next) { if (!strcmp(r->tag, tag)) { qemu_coroutine_enter(r->co, NULL); ret = 0; -- 1.8.5.1