Commit 779020cb authored by Kevin Wolf's avatar Kevin Wolf
Browse files

block: Allow bdrv_unref_child(bs, NULL)



bdrv_unref() can be called with a NULL argument and doesn't do anything
then. Make bdrv_unref_child() consistent with it.

Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
Reviewed-by: default avatarJeff Cody <jcody@redhat.com>
parent 8e419aef
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -1104,12 +1104,17 @@ static void bdrv_detach_child(BdrvChild *child)

void bdrv_unref_child(BlockDriverState *parent, BdrvChild *child)
{
    BlockDriverState *child_bs = child->bs;
    BlockDriverState *child_bs;

    if (child == NULL) {
        return;
    }

    if (child->bs->inherits_from == parent) {
        child->bs->inherits_from = NULL;
    }

    child_bs = child->bs;
    bdrv_detach_child(child);
    bdrv_unref(child_bs);
}