[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 05/21] parallels: return earlier from parallels_open() function o
From: |
Denis V. Lunev |
Subject: |
[PATCH 05/21] parallels: return earlier from parallels_open() function on error |
Date: |
Fri, 15 Sep 2023 20:41:13 +0200 |
At the beginning of the function we can return immediately until we
really allocate s->header.
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
block/parallels.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/block/parallels.c b/block/parallels.c
index 0f127427bf..8f223bfd89 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -1084,7 +1084,7 @@ static int parallels_open(BlockDriverState *bs, QDict
*options, int flags,
ret = bdrv_pread(bs->file, 0, sizeof(ph), &ph, 0);
if (ret < 0) {
- goto fail;
+ return ret;
}
bs->total_sectors = le64_to_cpu(ph.nb_sectors);
@@ -1104,13 +1104,11 @@ static int parallels_open(BlockDriverState *bs, QDict
*options, int flags,
s->tracks = le32_to_cpu(ph.tracks);
if (s->tracks == 0) {
error_setg(errp, "Invalid image: Zero sectors per track");
- ret = -EINVAL;
- goto fail;
+ return -EINVAL;
}
if (s->tracks > INT32_MAX/513) {
error_setg(errp, "Invalid image: Too big cluster");
- ret = -EFBIG;
- goto fail;
+ return -EFBIG;
}
s->prealloc_size = MAX(s->tracks, s->prealloc_size);
s->cluster_size = s->tracks << BDRV_SECTOR_BITS;
@@ -1118,16 +1116,14 @@ static int parallels_open(BlockDriverState *bs, QDict
*options, int flags,
s->bat_size = le32_to_cpu(ph.bat_entries);
if (s->bat_size > INT_MAX / sizeof(uint32_t)) {
error_setg(errp, "Catalog too large");
- ret = -EFBIG;
- goto fail;
+ return -EFBIG;
}
size = bat_entry_off(s->bat_size);
s->header_size = ROUND_UP(size, bdrv_opt_mem_align(bs->file->bs));
s->header = qemu_try_blockalign(bs->file->bs, s->header_size);
if (s->header == NULL) {
- ret = -ENOMEM;
- goto fail;
+ return -ENOMEM;
}
ret = bdrv_pread(bs->file, 0, s->header_size, s->header, 0);
--
2.34.1
- [PATCH 02/21] parallels: mark driver as supporting CBT, (continued)
- [PATCH 02/21] parallels: mark driver as supporting CBT, Denis V. Lunev, 2023/09/15
- [PATCH 08/21] tests: ensure that image validation will not cure the corruption, Denis V. Lunev, 2023/09/15
- [PATCH 01/21] parallels: fix formatting in bdrv_parallels initialization, Denis V. Lunev, 2023/09/15
- [PATCH 02/21] parallels: mark driver as supporting CBT, Denis V. Lunev, 2023/09/15
- [PATCH 07/21] parallels: create mark_used() helper which sets bit in used bitmap, Denis V. Lunev, 2023/09/15
- [PATCH 05/21] parallels: return earlier from parallels_open() function on error,
Denis V. Lunev <=
- [PATCH 09/21] parallels: fix broken parallels_check_data_off(), Denis V. Lunev, 2023/09/15
- [PATCH 16/21] parallels: naive implementation of allocate_clusters with used bitmap, Denis V. Lunev, 2023/09/15
- [PATCH 14/21] parallels: accept multiple clusters in mark_used(), Denis V. Lunev, 2023/09/15
- [PATCH 19/21] tests: extend test 131 to cover availability of the discard operation, Denis V. Lunev, 2023/09/15