]> xenbits.xensource.com Git - osstest/qemu.git/commitdiff
block: Allow bdrv_unref_child(bs, NULL)
authorKevin Wolf <kwolf@redhat.com>
Tue, 13 Oct 2015 12:09:44 +0000 (14:09 +0200)
committerKevin Wolf <kwolf@redhat.com>
Fri, 16 Oct 2015 13:34:30 +0000 (15:34 +0200)
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 <kwolf@redhat.com>
Reviewed-by: Jeff Cody <jcody@redhat.com>
block.c

diff --git a/block.c b/block.c
index f38146e2e86f2d5657bc5850188e2fccb3fcf28c..6490040b43a20003cba0c3c9edc0276d69131c72 100644 (file)
--- 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);
 }