From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60540) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VrWrk-0004oU-JY for qemu-devel@nongnu.org; Fri, 13 Dec 2013 12:49:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VrWre-0003rq-Fw for qemu-devel@nongnu.org; Fri, 13 Dec 2013 12:49:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:18524) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VrWre-0003rG-71 for qemu-devel@nongnu.org; Fri, 13 Dec 2013 12:49:26 -0500 From: Kevin Wolf Date: Fri, 13 Dec 2013 18:49:03 +0100 Message-Id: <1386956943-19474-7-git-send-email-kwolf@redhat.com> In-Reply-To: <1386956943-19474-1-git-send-email-kwolf@redhat.com> References: <1386956943-19474-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 6/6] blkdebug: Use QLIST_FOREACH_SAFE to resume IO List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Fam Zheng 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 Signed-off-by: Kevin Wolf --- 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.1.4