Skip to contentSkip to conversation

qcow2: Put cache reference in error case

PATCH In review Kevin Wolf 2 participants 2 messages Apr 4, 2014 Block layer

lore
Share & tools
lore

Kevin Wolf

author
#0 lore raw

PATCH 1/1 qcow2: Put cache reference in error case

When qcow2_get_cluster_offset() sees a zero cluster in a version 2 image, it (rightfully) returns an error. But in doing so it shouldn't leak an L2 table cache reference.

---
 block/qcow2-cluster.c | 1 +
 1 file changed, 1 insertion(+)
block/qcow2-cluster.c +1 -0
index 65550fd..54946c7 100644
@@ -495,6 +495,7 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset,
         break;
     case QCOW2_CLUSTER_ZERO:
         if (s->qcow_version < 3) {
+            qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
             return -EIO;
         }
         c = count_contiguous_clusters(nb_clusters, s->cluster_size,
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Kevin Wolf

When qcow2_get_cluster_offset() sees a zero cluster in a version 2 image, it (rightfully) returns an error. But in doing so it shouldn't leak an L2 table cache reference.

---
  block/qcow2-cluster.c | 1 +
  1 file changed, 1 insertion(+)