Skip to content

Commit

Permalink
qcow2: Put cache reference in error case
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
  • Loading branch information
kevmw committed Apr 4, 2014
1 parent 4c2e5f8 commit 8885ead
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions block/qcow2-cluster.c
Expand Up @@ -491,6 +491,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,
Expand Down

0 comments on commit 8885ead

Please sign in to comment.