summaryrefslogtreecommitdiffstats
path: root/block.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2015-10-13 14:09:44 +0200
committerKevin Wolf <kwolf@redhat.com>2015-10-16 15:34:30 +0200
commit779020cbdc67011026c10fb620f701bfc6b85547 (patch)
treedbfe62a69c310d81f0752b5780df5f95e01bc510 /block.c
parent8e419aefa07ca8e640f8db50b450378e84d60a11 (diff)
downloadhqemu-779020cbdc67011026c10fb620f701bfc6b85547.zip
hqemu-779020cbdc67011026c10fb620f701bfc6b85547.tar.gz
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 <kwolf@redhat.com> Reviewed-by: Jeff Cody <jcody@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r--block.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/block.c b/block.c
index f38146e..6490040 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);
}
OpenPOWER on IntegriCloud