Skip to content
Commit 178bd438 authored by Fam Zheng's avatar Fam Zheng
Browse files

block: Walk bs->children carefully in bdrv_drain_recurse



The recursive bdrv_drain_recurse may run a block job completion BH that
drops nodes. The coming changes will make that more likely and use-after-free
would happen without this patch

Stash the bs pointer and use bdrv_ref/bdrv_unref in addition to
QLIST_FOREACH_SAFE to prevent such a case from happening.

Since bdrv_unref accesses global state that is not protected by the AioContext
lock, we cannot use bdrv_ref/bdrv_unref unconditionally.  Fortunately the
protection is not needed in IOThread because only main loop can modify a graph
with the AioContext lock held.

Signed-off-by: default avatarFam Zheng <famz@redhat.com>
Message-Id: <20170418143044.12187-2-famz@redhat.com>
Reviewed-by: default avatarJeff Cody <jcody@redhat.com>
Tested-by: default avatarJeff Cody <jcody@redhat.com>
Signed-off-by: default avatarFam Zheng <famz@redhat.com>
parent 9c6b899f
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment