diff options
author | Kevin Wolf <kwolf@redhat.com> | 2016-05-20 18:49:07 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2016-05-25 19:04:10 +0200 |
commit | 88be7b4be4aa17c88247e162bdd7577ea79db94f (patch) | |
tree | cec7d9da5079f6dba0c65945925aedfd8c77267c /monitor.c | |
parent | 287db79df8af8e31f18e262feb5e05103a09e4d4 (diff) | |
download | qemu-88be7b4be4aa17c88247e162bdd7577ea79db94f.zip qemu-88be7b4be4aa17c88247e162bdd7577ea79db94f.tar.gz qemu-88be7b4be4aa17c88247e162bdd7577ea79db94f.tar.bz2 |
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>
Diffstat (limited to 'monitor.c')
-rw-r--r-- | monitor.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -3432,12 +3432,12 @@ static void vm_completion(ReadLineState *rs, const char *str) { size_t len; BlockDriverState *bs; - BdrvNextIterator *it = NULL; + BdrvNextIterator it; len = strlen(str); readline_set_completion_index(rs, len); - while ((it = bdrv_next(it, &bs))) { + for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) { SnapshotInfoList *snapshots, *snapshot; AioContext *ctx = bdrv_get_aio_context(bs); bool ok = false; |