[Devel] [PATCH RHEL9 COMMIT] dm-qcow2: Fix unsigned type in parse_metadata()
Konstantin Khorenko
khorenko at virtuozzo.com
Wed Jan 26 14:17:44 MSK 2022
The commit is pushed to "branch-rh9-5.14.0-4.vz9.12.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh9-5.14.0-4.vz9.12.2
------>
commit dfb58c41ad3a5cd663f836cfaf984a6bae527e10
Author: Kirill Tkhai <ktkhai at virtuozzo.com>
Date: Wed Jan 26 14:12:53 2022 +0300
dm-qcow2: Fix unsigned type in parse_metadata()
This never exposes error otherwise.
(pos - u64 and it is never less than zero).
Fixes: 4623783368b0 ("dm-qcow2: Introduce driver to create block devices over
QCOW2 files")
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
drivers/md/dm-qcow2-map.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c
index 587068990424..bff0f5b54564 100644
--- a/drivers/md/dm-qcow2-map.c
+++ b/drivers/md/dm-qcow2-map.c
@@ -1928,7 +1928,7 @@ static int parse_metadata(struct qcow2 *qcow2, struct qio **qio,
{
struct md_page *md;
u64 pos;
- int ret;
+ s64 ret;
WARN_ON_ONCE(map->data_clu_pos != 0);
if (calc_cluster_map(qcow2, *qio, map) < 0)
@@ -1942,9 +1942,9 @@ static int parse_metadata(struct qcow2 *qcow2, struct qio **qio,
map->level = L1_LEVEL;
/* Find L2 cluster (from L1 page) */
- pos = parse_l1(qcow2, map, qio, write);
- if (pos <= 0) /* Err, delayed, L2 is not allocated, or zero read */
- return pos;
+ pos = ret = parse_l1(qcow2, map, qio, write);
+ if (ret <= 0) /* Err, delayed, L2 is not allocated, or zero read */
+ return ret;
/* pos is start of cluster */
pos += map->l2.index * sizeof(u64);
@@ -1958,9 +1958,9 @@ static int parse_metadata(struct qcow2 *qcow2, struct qio **qio,
map->level |= L2_LEVEL;
/* Find DATA cluster (from L2 page) */
- pos = parse_l2(qcow2, map, qio, write);
- if (pos <= 0) /* Err, delayed, DATA is not allocated, or zero read */
- return pos;
+ pos = ret = parse_l2(qcow2, map, qio, write);
+ if (ret <= 0) /* Err, delayed, DATA is not allocated, or zero read */
+ return ret;
map->data_clu_pos = pos;
if (!write || !map->clu_is_cow)
More information about the Devel
mailing list