]> git.proxmox.com Git - mirror_qemu.git/commit - migration/block.c
block: Fix bdrv_next() memory leak
authorKevin Wolf <kwolf@redhat.com>
Fri, 20 May 2016 16:49:07 +0000 (18:49 +0200)
committerKevin Wolf <kwolf@redhat.com>
Wed, 25 May 2016 17:04:10 +0000 (19:04 +0200)
commit88be7b4be4aa17c88247e162bdd7577ea79db94f
treecec7d9da5079f6dba0c65945925aedfd8c77267c
parent287db79df8af8e31f18e262feb5e05103a09e4d4
block: Fix bdrv_next() memory leak

The bdrv_next() users all leaked the BdrvNextIterator after completing
the iteration. Simply changing bdrv_next() to free the iterator before
returning NULL at the end of list doesn't work because some callers exit
the loop before looking at all BDSes.

This patch moves the BdrvNextIterator from the heap to the stack of
the caller and switches to a bdrv_first()/bdrv_next() interface for
initialising the iterator.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
block.c
block/block-backend.c
block/io.c
block/snapshot.c
blockdev.c
include/block/block.h
migration/block.c
monitor.c
qmp.c