diff options
author | Jeff Cody <jcody@redhat.com> | 2014-07-23 17:22:57 -0400 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2014-08-15 15:07:14 +0200 |
commit | 9a4d5ca60772e09d0cbac01f1b4778aa68e00eaa (patch) | |
tree | 2d42ce46e2fcc8a311d8ddc519494130b587b28e /block.c | |
parent | 58803ce74f986785badfb2ef0f630e1cd97f52e5 (diff) |
block: allow bdrv_unref() to be passed NULL pointers
If bdrv_unref() is passed a NULL BDS pointer, it is safe to
exit with no operation. This will allow cleanup code to blindly
call bdrv_unref() on a BDS that has been initialized to NULL.
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r-- | block.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -5381,6 +5381,9 @@ void bdrv_ref(BlockDriverState *bs) * deleted. */ void bdrv_unref(BlockDriverState *bs) { + if (!bs) { + return; + } assert(bs->refcnt > 0); if (--bs->refcnt == 0) { bdrv_delete(bs); |