cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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