From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55730) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZlyWi-0001dR-G8 for qemu-devel@nongnu.org; Tue, 13 Oct 2015 08:17:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZlyWe-0005YD-Pq for qemu-devel@nongnu.org; Tue, 13 Oct 2015 08:17:56 -0400 From: Kevin Wolf Date: Tue, 13 Oct 2015 14:17:39 +0200 Message-Id: <1444738660-18285-2-git-send-email-kwolf@redhat.com> In-Reply-To: <1444738660-18285-1-git-send-email-kwolf@redhat.com> References: <1444738660-18285-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 1/2] block: Allow bdrv_unref_child(bs, NULL) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: kwolf@redhat.com, jcody@redhat.com, qemu-devel@nongnu.org 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 --- 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