No description
Find a file
Luiz Capitulino 8f91ad8a1b qapi: qapi-commands: fix possible leaks on visitor dealloc
In qmp-marshal.c the dealloc visitor calls use the same errp
pointer of the input visitor calls. This means that if any of
the input visitor calls fails, then the dealloc visitor will
return early, before freeing the object's memory.

Here's an example, consider this code:

int qmp_marshal_input_block_passwd(Monitor *mon, const QDict *qdict, QObject **ret)
{
	[...]

    char * device = NULL;
    char * password = NULL;

    mi = qmp_input_visitor_new_strict(QOBJECT(args));
    v = qmp_input_get_visitor(mi);
    visit_type_str(v, &device, "device", errp);
    visit_type_str(v, &password, "password", errp);
    qmp_input_visitor_cleanup(mi);

    if (error_is_set(errp)) {
        goto out;
    }
    qmp_block_passwd(device, password, errp);

out:
    md = qapi_dealloc_visitor_new();
    v = qapi_dealloc_get_visitor(md);
    visit_type_str(v, &device, "device", errp);
    visit_type_str(v, &password, "password", errp);
    qapi_dealloc_visitor_cleanup(md);

	[...]

    return 0;
}

Consider errp != NULL when the out label is reached, we're going
to leak device and password.

This patch fixes this by always passing errp=NULL for dealloc
visitors, meaning that we always try to free them regardless of
any previous failure. The above example would then be:

out:
    md = qapi_dealloc_visitor_new();
    v = qapi_dealloc_get_visitor(md);
    visit_type_str(v, &device, "device", NULL);
    visit_type_str(v, &password, "password", NULL);
    qapi_dealloc_visitor_cleanup(md);

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com>
2013-07-16 09:15:06 -04:00
audio
backends
block block: Don't parse protocol from file.filename 2013-07-15 09:49:00 +02:00
bsd-user bsd-user: Change thread_env to CPUState 2013-07-09 21:33:01 +02:00
default-configs pseries: move interrupt controllers to hw/intc/ 2013-07-11 18:51:23 +02:00
disas
docs add a header file for atomic operations 2013-07-04 17:42:49 +02:00
dtc@bc895d6d09
fpu
fsdev fsdev: Fix potential memory leak 2013-07-09 13:38:56 -05:00
gdb-xml
hw Merge remote-tracking branch 'cohuck/virtio-ccw-upstr' into staging 2013-07-15 14:02:41 -05:00
include Merge remote-tracking branch 'quintela/migration.next' into staging 2013-07-15 14:49:16 -05:00
ldscripts
libcacard
linux-headers
linux-user QOM CPUState refactorings 2013-07-10 10:54:16 -05:00
net
pc-bios
pixman@97336fad32
po
qapi
qga
QMP
qobject
qom QOM CPUState refactorings 2013-07-10 10:54:16 -05:00
roms
scripts qapi: qapi-commands: fix possible leaks on visitor dealloc 2013-07-16 09:15:06 -04:00
slirp
stubs cpus: Add return value for vm_stop() 2013-07-15 09:51:38 +02:00
sysconfigs/target
target-alpha target-alpha: Change gen_intermediate_code_internal() argument to AlphaCPU 2013-07-09 21:33:03 +02:00
target-arm target-arm: Avoid g_hash_table_get_keys() 2013-07-15 17:13:51 +01:00
target-cris cpu: Move reset logging to CPUState 2013-07-09 21:33:04 +02:00
target-i386 QOM CPUState refactorings 2013-07-10 10:54:16 -05:00
target-lm32 cpu: Move reset logging to CPUState 2013-07-09 21:33:04 +02:00
target-m68k cpu: Move reset logging to CPUState 2013-07-09 21:33:04 +02:00
target-microblaze cpu: Move reset logging to CPUState 2013-07-09 21:33:04 +02:00
target-mips cpu: Move reset logging to CPUState 2013-07-09 21:33:04 +02:00
target-moxie cpu: Move reset logging to CPUState 2013-07-09 21:33:04 +02:00
target-openrisc cpu: Move reset logging to CPUState 2013-07-09 21:33:04 +02:00
target-ppc target-ppc: Add POWER8 v1.0 CPU model 2013-07-11 18:51:23 +02:00
target-s390x cpu: Move reset logging to CPUState 2013-07-09 21:33:04 +02:00
target-sh4 cpu: Move reset logging to CPUState 2013-07-09 21:33:04 +02:00
target-sparc cpu: Move reset logging to CPUState 2013-07-09 21:33:04 +02:00
target-unicore32 target-unicore32: Change gen_intermediate_code_internal() signature 2013-07-09 21:33:04 +02:00
target-xtensa target-xtensa: Change gen_intermediate_code_internal() arg to XtensaCPU 2013-07-09 21:33:04 +02:00
tcg tcg-arm: Implement tcg_register_jit 2013-07-09 07:15:25 -07:00
tests qemu-iotests: Update 051 reference output 2013-07-15 09:49:00 +02:00
trace
ui
util add timestamp to error_report() 2013-07-10 13:42:09 -04:00
.exrc
.gitignore
.gitmodules
.mailmap
aio-posix.c
aio-win32.c
arch_init.c Force auto-convegence of live migration 2013-07-12 20:35:08 +02:00
async.c
balloon.c
block-migration.c
block.c block: Add return value for bdrv_flush_all() 2013-07-15 09:51:27 +02:00
blockdev-nbd.c
blockdev.c blockdev: add sync mode to drive-backup QMP command 2013-07-15 09:49:00 +02:00
blockjob.c
bt-host.c
bt-vhci.c
Changelog
CODING_STYLE
configure configure: Simplify alternate .text segment 2013-07-09 13:13:20 -05:00
COPYING
COPYING.LIB
coroutine-gthread.c
coroutine-sigaltstack.c
coroutine-ucontext.c
coroutine-win32.c
cpu-exec.c log: Change log_cpu_state[_mask]() argument to CPUState 2013-07-09 21:33:04 +02:00
cpus.c Merge remote-tracking branch 'quintela/migration.next' into staging 2013-07-15 14:49:16 -05:00
cputlb.c cpu: Make first_cpu and next_cpu CPUState 2013-07-09 21:32:54 +02:00
device-hotplug.c
device_tree.c vl: Tighten parsing of -machine option phandle_start 2013-07-09 13:38:58 -05:00
disas.c
dma-helpers.c
dump.c cpu: Make first_cpu and next_cpu CPUState 2013-07-09 21:32:54 +02:00
exec.c exec: Support 64-bit operations in address_space_rw 2013-07-14 13:40:31 -07:00
gdbstub.c cpu: Make first_cpu and next_cpu CPUState 2013-07-09 21:32:54 +02:00
HACKING
hmp-commands.hx block: add drive_backup HMP command 2013-07-15 09:49:00 +02:00
hmp.c block: add drive_backup HMP command 2013-07-15 09:49:00 +02:00
hmp.h block: add drive_backup HMP command 2013-07-15 09:49:00 +02:00
iohandler.c
ioport.c ioport: remove LITTLE_ENDIAN mark for portio 2013-07-12 14:37:47 -05:00
kvm-all.c QOM CPUState refactorings 2013-07-10 10:54:16 -05:00
kvm-stub.c kvm: Change kvm_remove_all_breakpoints() argument to CPUState 2013-07-09 21:20:28 +02:00
LICENSE
main-loop.c
MAINTAINERS tcg: Add myself to general TCG maintainership 2013-07-08 22:03:59 -07:00
Makefile
Makefile.objs
Makefile.target
memory.c cpu: Replace cpu_single_env with CPUState current_cpu 2013-07-09 21:20:28 +02:00
memory_mapping.c cpu: Make first_cpu and next_cpu CPUState 2013-07-09 21:32:54 +02:00
migration-exec.c
migration-fd.c
migration-tcp.c
migration-unix.c
migration.c Merge remote-tracking branch 'quintela/migration.next' into staging 2013-07-15 14:49:16 -05:00
monitor.c cpu: Make first_cpu and next_cpu CPUState 2013-07-09 21:32:54 +02:00
nbd.c
os-posix.c
os-win32.c
page_cache.c
qapi-schema-test.json
qapi-schema.json Merge remote-tracking branch 'quintela/migration.next' into staging 2013-07-15 14:49:16 -05:00
qdev-monitor.c
qdict-test-data.txt
qemu-bridge-helper.c
qemu-char.c qemu-char: Fix ringbuf option size 2013-07-10 13:39:37 -04:00
qemu-coroutine-io.c
qemu-coroutine-lock.c
qemu-coroutine-sleep.c
qemu-coroutine.c
qemu-doc.texi
qemu-img-cmds.hx
qemu-img.c block: Don't parse protocol from file.filename 2013-07-15 09:49:00 +02:00
qemu-img.texi
qemu-io-cmds.c
qemu-io.c
qemu-log.c
qemu-nbd.c
qemu-nbd.texi
qemu-options-wrapper.h
qemu-options.h
qemu-options.hx add timestamp to error_report() 2013-07-10 13:42:09 -04:00
qemu-seccomp.c
qemu-tech.texi
qemu-timer.c
qemu.sasl
qmp-commands.hx blockdev: add sync mode to drive-backup QMP command 2013-07-15 09:49:00 +02:00
qmp.c
qtest.c
readline.c
README
rules.mak
savevm.c
spice-qemu-char.c
tcg-runtime.c
tci.c
thread-pool.c
thunk.c
tpm.c
trace-events Force auto-convegence of live migration 2013-07-12 20:35:08 +02:00
translate-all.c cpu: Make first_cpu and next_cpu CPUState 2013-07-09 21:32:54 +02:00
translate-all.h
user-exec.c QOM CPUState refactorings 2013-07-10 10:54:16 -05:00
VERSION
version.rc
vl.c add timestamp to error_report() 2013-07-10 13:42:09 -04:00
xbzrle.c
xen-all.c
xen-mapcache.c
xen-stub.c

Read the documentation in qemu-doc.html or on http://wiki.qemu.org

- QEMU team