qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, jcody@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 1/2] block: Allow bdrv_unref_child(bs, NULL)
Date: Tue, 13 Oct 2015 14:17:39 +0200	[thread overview]
Message-ID: <1444738660-18285-2-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1444738660-18285-1-git-send-email-kwolf@redhat.com>

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>
---
 block.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

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);
 }
-- 
1.8.3.1

  reply	other threads:[~2015-10-13 12:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-13 12:17 [Qemu-devel] [PATCH 0/2] blkverify: Fix BDS leak in .bdrv_open error path Kevin Wolf
2015-10-13 12:17 ` Kevin Wolf [this message]
2015-10-13 12:22   ` [Qemu-devel] [PATCH 1/2] block: Allow bdrv_unref_child(bs, NULL) Jeff Cody
2015-10-13 12:17 ` [Qemu-devel] [PATCH 2/2] blkverify: Fix BDS leak in .bdrv_open error path Kevin Wolf
2015-10-13 12:35   ` Jeff Cody
2015-10-26 11:26 ` [Qemu-devel] [Qemu-block] [PATCH 0/2] " Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1444738660-18285-2-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=jcody@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).