]> git.proxmox.com Git - pve-qemu.git/blob - debian/patches/pve/0062-block-alloc-track-avoid-premature-break.patch
a3c4909b410dc2f3ea5e2f2743104167cb531c78
[pve-qemu.git] / debian / patches / pve / 0062-block-alloc-track-avoid-premature-break.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Fabian Ebner <f.ebner@proxmox.com>
3 Date: Wed, 22 Jun 2022 10:45:13 +0200
4 Subject: [PATCH] block: alloc-track: avoid premature break
5
6 While the bdrv_co_preadv() calls are expected to return 0 on success,
7 qemu_iovec_memset() will return the number of bytes set (will be
8 local_bytes, because the slice with that size was just initialized).
9
10 Don't break out of the loop after the branch with qemu_iovec_memset(),
11 because there might still be work to do. Additionally, ret is an int,
12 which on 64-bit platforms is too small to hold the size_t returned by
13 qemu_iovec_memset().
14
15 The branch seems to be difficult to reach in practice, because the
16 whole point of alloc-track is to be used with a backing device.
17
18 Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
19 ---
20 block/alloc-track.c | 3 ++-
21 1 file changed, 2 insertions(+), 1 deletion(-)
22
23 diff --git a/block/alloc-track.c b/block/alloc-track.c
24 index 6b50fbe537..c1160af04b 100644
25 --- a/block/alloc-track.c
26 +++ b/block/alloc-track.c
27 @@ -174,7 +174,8 @@ static int coroutine_fn track_co_preadv(BlockDriverState *bs,
28 ret = bdrv_co_preadv(bs->backing, local_offset, local_bytes,
29 &local_qiov, flags);
30 } else {
31 - ret = qemu_iovec_memset(&local_qiov, cur_offset, 0, local_bytes);
32 + qemu_iovec_memset(&local_qiov, cur_offset, 0, local_bytes);
33 + ret = 0;
34 }
35
36 if (ret != 0) {