qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PULL 34/62] block: allow bdrv_unref() to be passed NULL po


From: Kevin Wolf
Subject: [Qemu-devel] [PULL 34/62] block: allow bdrv_unref() to be passed NULL pointers
Date: Fri, 8 Aug 2014 19:39:35 +0200

From: Jeff Cody <address@hidden>

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 <address@hidden>
Signed-off-by: Jeff Cody <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
 block.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/block.c b/block.c
index 13a1059..a8962ab 100644
--- a/block.c
+++ b/block.c
@@ -5388,6 +5388,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);
-- 
1.8.3.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]