aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2012-05-24 12:56:32 +0200
committerKevin Wolf <kwolf@redhat.com>2012-05-25 18:12:54 +0200
commitdf021791897cb7a171710dadf66648b4379de627 (patch)
tree4f0f2c1b77f897f3e25397f1dfcf75ee2b8c8c5f
parentb6fc8245e96dea6b7198a46e883d107403ddb90c (diff)
downloadqemu-df021791897cb7a171710dadf66648b4379de627.zip
qemu-df021791897cb7a171710dadf66648b4379de627.tar.gz
qemu-df021791897cb7a171710dadf66648b4379de627.tar.bz2
qcow2: Check qcow2_alloc_clusters_at() return value
When using qcow2_alloc_clusters_at(), the cluster allocation code checked the wrong variable for an error code. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r--block/qcow2-cluster.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index 10c22fe..4b3345b 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -762,7 +762,6 @@ static int do_alloc_cluster_offset(BlockDriverState *bs, uint64_t guest_offset,
uint64_t *host_offset, unsigned int *nb_clusters)
{
BDRVQcowState *s = bs->opaque;
- int64_t cluster_offset;
QCowL2Meta *old_alloc;
trace_qcow2_do_alloc_clusters_offset(qemu_coroutine_self(), guest_offset,
@@ -808,17 +807,21 @@ static int do_alloc_cluster_offset(BlockDriverState *bs, uint64_t guest_offset,
/* Allocate new clusters */
trace_qcow2_cluster_alloc_phys(qemu_coroutine_self());
if (*host_offset == 0) {
- cluster_offset = qcow2_alloc_clusters(bs, *nb_clusters * s->cluster_size);
+ int64_t cluster_offset =
+ qcow2_alloc_clusters(bs, *nb_clusters * s->cluster_size);
+ if (cluster_offset < 0) {
+ return cluster_offset;
+ }
+ *host_offset = cluster_offset;
+ return 0;
} else {
- cluster_offset = *host_offset;
- *nb_clusters = qcow2_alloc_clusters_at(bs, cluster_offset, *nb_clusters);
- }
-
- if (cluster_offset < 0) {
- return cluster_offset;
+ int ret = qcow2_alloc_clusters_at(bs, *host_offset, *nb_clusters);
+ if (ret < 0) {
+ return ret;
+ }
+ *nb_clusters = ret;
+ return 0;
}
- *host_offset = cluster_offset;
- return 0;
}
/*