[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 02/15] qemu-config: fix memory leak on ferror()
From: |
Paolo Bonzini |
Subject: |
[PULL 02/15] qemu-config: fix memory leak on ferror() |
Date: |
Thu, 22 Jul 2021 17:35:59 +0200 |
The leak is basically impossible to reach, since the only common way
to get ferror(fp) is by passing a directory to -readconfig. In that
case, the error occurs before qdict is set to anything non-NULL.
However, it's theoretically possible to get there after an EIO.
Cc: armbru@redhat.com
Reported-by: Peter Maydell <peter.maydell@linaro.org>
Fixes: f7544edcd3 ("qemu-config: add error propagation to qemu_config_parse",
2021-03-06)
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
util/qemu-config.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/util/qemu-config.c b/util/qemu-config.c
index 7db810f1e0..fdf6cd69fc 100644
--- a/util/qemu-config.c
+++ b/util/qemu-config.c
@@ -414,7 +414,7 @@ static int qemu_config_foreach(FILE *fp, QEMUConfigCB *cb,
void *opaque,
if (ferror(fp)) {
loc_pop(&loc);
error_setg_errno(errp, errno, "Cannot read config file");
- return res;
+ goto out_no_loc;
}
res = count;
if (qdict) {
@@ -422,6 +422,7 @@ static int qemu_config_foreach(FILE *fp, QEMUConfigCB *cb,
void *opaque,
}
out:
loc_pop(&loc);
+out_no_loc:
qobject_unref(qdict);
return res;
}
--
2.31.1
- [PULL 00/15] Misc bugfix patches for 2021-07-22, Paolo Bonzini, 2021/07/22
- [PULL 01/15] qemu-config: never call the callback after an error, fix leak, Paolo Bonzini, 2021/07/22
- [PULL 06/15] qemu-config: restore "machine" in qmp_query_command_line_options(), Paolo Bonzini, 2021/07/22
- [PULL 09/15] target/i386: Added consistency checks for EFER, Paolo Bonzini, 2021/07/22
- [PULL 08/15] target/i386: Added consistency checks for CR4, Paolo Bonzini, 2021/07/22
- [PULL 04/15] chardev-spice: add missing module_obj directive, Paolo Bonzini, 2021/07/22
- [PULL 02/15] qemu-config: fix memory leak on ferror(),
Paolo Bonzini <=
- [PULL 11/15] meson: fix dependencies for modinfo, Paolo Bonzini, 2021/07/22
- [PULL 10/15] configure: Drop obsolete check for the alloc_size attribute, Paolo Bonzini, 2021/07/22
- [PULL 13/15] configure: Allow vnc to get disabled with --without-default-features, Paolo Bonzini, 2021/07/22
- [PULL 15/15] configure: Let --without-default-features disable vhost-kernel and vhost-vdpa, Paolo Bonzini, 2021/07/22
- [PULL 03/15] vl: Parse legacy default_machine_opts, Paolo Bonzini, 2021/07/22
- [PULL 07/15] target/i386: Added V_INTR_PRIO check to virtual interrupts, Paolo Bonzini, 2021/07/22
- [PULL 05/15] usb: fix usb-host dependency check, Paolo Bonzini, 2021/07/22
- [PULL 14/15] configure: Fix the default setting of the "xen" feature, Paolo Bonzini, 2021/07/22
- [PULL 12/15] configure: Fix --without-default-features propagation to meson, Paolo Bonzini, 2021/07/22
- Re: [PULL 00/15] Misc bugfix patches for 2021-07-22, Peter Maydell, 2021/07/23