diff mbox series

[kvmtool,1/9] qcow: Fix qcow1 exit fault

Message ID 20190218130702.32575-2-jean-philippe.brucker@arm.com (mailing list archive)
State New, archived
Headers show
Series Disk fixes and AIO reset | expand

Commit Message

Jean-Philippe Brucker Feb. 18, 2019, 1:06 p.m. UTC
Even though qcow1 doesn't use the refcount table, the cleanup path still
attempts to iterate over its LRU list. Initialize the list to avoid a
segfault on exit.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
---
 disk/qcow.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Andre Przywara Feb. 22, 2019, 4:36 p.m. UTC | #1
On Mon, 18 Feb 2019 13:06:54 +0000
Jean-Philippe Brucker <jean-philippe.brucker@arm.com> wrote:

> Even though qcow1 doesn't use the refcount table, the cleanup path still
> attempts to iterate over its LRU list. Initialize the list to avoid a
> segfault on exit.

That's correct, qcow1 and qcow2 share the same qcow_disk_close() function,
which references the list.

> Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>

Reviewed-by: Andre Przywara <andre.przywara@arm.com>

Cheers,
Andre.

> ---
>  disk/qcow.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/disk/qcow.c b/disk/qcow.c
> index 64cf9270a..bed70c65c 100644
> --- a/disk/qcow.c
> +++ b/disk/qcow.c
> @@ -1437,6 +1437,7 @@ static struct disk_image *qcow1_probe(int fd, bool readonly)
>  
>  	l1t->root = (struct rb_root)RB_ROOT;
>  	INIT_LIST_HEAD(&l1t->lru_list);
> +	INIT_LIST_HEAD(&q->refcount_table.lru_list);
>  
>  	h = q->header = qcow1_read_header(fd);
>  	if (!h)
diff mbox series

Patch

diff --git a/disk/qcow.c b/disk/qcow.c
index 64cf9270a..bed70c65c 100644
--- a/disk/qcow.c
+++ b/disk/qcow.c
@@ -1437,6 +1437,7 @@  static struct disk_image *qcow1_probe(int fd, bool readonly)
 
 	l1t->root = (struct rb_root)RB_ROOT;
 	INIT_LIST_HEAD(&l1t->lru_list);
+	INIT_LIST_HEAD(&q->refcount_table.lru_list);
 
 	h = q->header = qcow1_read_header(fd);
 	if (!h)