[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/2] block: Allow bdrv_unref_child(bs, NULL)
From: |
Jeff Cody |
Subject: |
Re: [Qemu-devel] [PATCH 1/2] block: Allow bdrv_unref_child(bs, NULL) |
Date: |
Tue, 13 Oct 2015 08:22:22 -0400 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
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 <address@hidden>
> ---
> 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 <address@hidden>