Skip to content

Commit

Permalink
Allow nested qemu_bh_poll() after BH deletion
Browse files Browse the repository at this point in the history
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 <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
  • Loading branch information
kevmw committed Jun 15, 2011
1 parent ee752da commit 7887f62
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions async.c
Expand Up @@ -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)
Expand Down

0 comments on commit 7887f62

Please sign in to comment.