Blame SOURCES/kvm-block-allow-bdrv_unref-to-be-passed-NULL-pointers.patch

958e1b
From 9a9800bbe9e2a38adaccc98314fff2354a52037e Mon Sep 17 00:00:00 2001
958e1b
From: Jeffrey Cody <jcody@redhat.com>
958e1b
Date: Tue, 16 Sep 2014 20:11:50 +0200
958e1b
Subject: [PATCH 12/20] block: allow bdrv_unref() to be passed NULL pointers
958e1b
958e1b
Message-id: <aadda07926a2fbf063041cd73b68b8846ff677ed.1410897407.git.jcody@redhat.com>
958e1b
Patchwork-id: 61216
958e1b
O-Subject: [PATCH qemu-kvm-rhel RHEL7.1 11/15] block: allow bdrv_unref() to be passed NULL pointers
958e1b
Bugzilla: 1098086
958e1b
RH-Acked-by: Fam Zheng <famz@redhat.com>
958e1b
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
958e1b
RH-Acked-by: Max Reitz <mreitz@redhat.com>
958e1b
958e1b
If bdrv_unref() is passed a NULL BDS pointer, it is safe to
958e1b
exit with no operation.  This will allow cleanup code to blindly
958e1b
call bdrv_unref() on a BDS that has been initialized to NULL.
958e1b
958e1b
Reviewed-by: Max Reitz <mreitz@redhat.com>
958e1b
Signed-off-by: Jeff Cody <jcody@redhat.com>
958e1b
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
958e1b
(cherry picked from commit 9a4d5ca60772e09d0cbac01f1b4778aa68e00eaa)
958e1b
958e1b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
958e1b
---
958e1b
 block.c |    3 +++
958e1b
 1 files changed, 3 insertions(+), 0 deletions(-)
958e1b
958e1b
diff --git a/block.c b/block.c
958e1b
index a2e95f6..af162fe 100644
958e1b
--- a/block.c
958e1b
+++ b/block.c
958e1b
@@ -5083,6 +5083,9 @@ void bdrv_ref(BlockDriverState *bs)
958e1b
  * deleted. */
958e1b
 void bdrv_unref(BlockDriverState *bs)
958e1b
 {
958e1b
+    if (!bs) {
958e1b
+        return;
958e1b
+    }
958e1b
     assert(bs->refcnt > 0);
958e1b
     if (--bs->refcnt == 0) {
958e1b
         bdrv_delete(bs);
958e1b
-- 
958e1b
1.7.1
958e1b