From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57936) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zlyb7-0007CI-GP for qemu-devel@nongnu.org; Tue, 13 Oct 2015 08:22:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zlyb6-0007Q1-Mn for qemu-devel@nongnu.org; Tue, 13 Oct 2015 08:22:29 -0400 Date: Tue, 13 Oct 2015 08:22:22 -0400 From: Jeff Cody Message-ID: <20151013122222.GC10945@localhost.localdomain> References: <1444738660-18285-1-git-send-email-kwolf@redhat.com> <1444738660-18285-2-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1444738660-18285-2-git-send-email-kwolf@redhat.com> Subject: Re: [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: Kevin Wolf Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org On Tue, Oct 13, 2015 at 02:17:39PM +0200, Kevin Wolf wrote: > 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 > Reviewed-by: Jeff Cody