9ae3a8
From 9c887fdb82a6500aec6897f5c7f48f6bd31a33fc Mon Sep 17 00:00:00 2001
9ae3a8
From: Max Reitz <mreitz@redhat.com>
9ae3a8
Date: Sat, 13 Jun 2015 16:21:55 +0200
9ae3a8
Subject: [PATCH 01/42] qcow2: Put cache reference in error case
9ae3a8
9ae3a8
Message-id: <1434212556-3927-2-git-send-email-mreitz@redhat.com>
9ae3a8
Patchwork-id: 66020
9ae3a8
O-Subject: [RHEL-7.2 qemu-kvm PATCH 01/42] qcow2: Put cache reference in error case
9ae3a8
Bugzilla: 1129893
9ae3a8
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
9ae3a8
RH-Acked-by: Fam Zheng <famz@redhat.com>
9ae3a8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
9ae3a8
From: Kevin Wolf <kwolf@redhat.com>
9ae3a8
9ae3a8
BZ: 1129893
9ae3a8
9ae3a8
When qcow2_get_cluster_offset() sees a zero cluster in a version 2
9ae3a8
image, it (rightfully) returns an error. But in doing so it shouldn't
9ae3a8
leak an L2 table cache reference.
9ae3a8
9ae3a8
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
9ae3a8
Reviewed-by: Max Reitz <mreitz@redhat.com>
9ae3a8
(cherry picked from commit 8885eadedd0ea8b57c1baa367ee2c2d616700bd9)
9ae3a8
9ae3a8
Signed-off-by: Max Reitz <mreitz@redhat.com>
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 block/qcow2-cluster.c | 1 +
9ae3a8
 1 file changed, 1 insertion(+)
9ae3a8
9ae3a8
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
9ae3a8
index 81d90d9..1b9609f 100644
9ae3a8
--- a/block/qcow2-cluster.c
9ae3a8
+++ b/block/qcow2-cluster.c
9ae3a8
@@ -481,6 +481,7 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset,
9ae3a8
         break;
9ae3a8
     case QCOW2_CLUSTER_ZERO:
9ae3a8
         if (s->qcow_version < 3) {
9ae3a8
+            qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
9ae3a8
             return -EIO;
9ae3a8
         }
9ae3a8
         c = count_contiguous_clusters(nb_clusters, s->cluster_size,
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8