Received: from eggs.gnu.org ([140.186.70.92]:35156) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QWqeB-0003ky-Mv for qemu-devel@nongnu.org; Wed, 15 Jun 2011 10:00:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QWqe9-0005vM-Cy for qemu-devel@nongnu.org; Wed, 15 Jun 2011 10:00:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:62459) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QWqe8-0005v2-QU for qemu-devel@nongnu.org; Wed, 15 Jun 2011 10:00:41 -0400 From: Kevin Wolf Date: Wed, 15 Jun 2011 16:03:13 +0200 Message-Id: <1308146593-19842-15-git-send-email-kwolf@redhat.com> In-Reply-To: <1308146593-19842-1-git-send-email-kwolf@redhat.com> References: <1308146593-19842-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 14/14] Allow nested qemu_bh_poll() after BH deletion List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org Without this, qemu segfaults when a BH handler first deletes its BH and then calls another function which involves a nested qemu_bh_poll() call. This can be reproduced by generating an I/O error (e.g. with blkdebug) on an IDE device and using rerror/werror=stop to stop the VM. When continuing the VM, qemu segfaults. Signed-off-by: Kevin Wolf Reviewed-by: Stefan Hajnoczi --- async.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/async.c b/async.c index 57ac3a8..fd313df 100644 --- a/async.c +++ b/async.c @@ -137,11 +137,12 @@ QEMUBH *qemu_bh_new(QEMUBHFunc *cb, void *opaque) int qemu_bh_poll(void) { - QEMUBH *bh, **bhp; + QEMUBH *bh, **bhp, *next; int ret; ret = 0; - for (bh = async_context->first_bh; bh; bh = bh->next) { + for (bh = async_context->first_bh; bh; bh = next) { + next = bh->next; if (!bh->deleted && bh->scheduled) { bh->scheduled = 0; if (!bh->idle) -- 1.7.5.2