From: Kevin Wolf Date: Tue, 13 Oct 2015 12:09:44 +0000 (+0200) Subject: block: Allow bdrv_unref_child(bs, NULL) X-Git-Tag: v2.5.0-rc0~70^2~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=779020cbdc67011026c10fb620f701bfc6b85547;p=thirdparty%2Fqemu.git 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: Kevin Wolf Reviewed-by: Jeff Cody --- diff --git a/block.c b/block.c index f38146e2e86..6490040b43a 100644 --- a/block.c +++ b/block.c @@ -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); }