diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2021-07-05 19:14:37 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2021-07-20 17:06:28 +0200 |
commit | 461fea9bf1db0e122cfc18ea07958ddebea5d9a3 (patch) | |
tree | 31176b9626ad7d2d32c13767accb7b30c9ced8e6 | |
parent | e72f9524febb78ee5ae2a201245cd7b1fb97ad08 (diff) | |
download | qemu-461fea9bf1db0e122cfc18ea07958ddebea5d9a3.zip qemu-461fea9bf1db0e122cfc18ea07958ddebea5d9a3.tar.gz qemu-461fea9bf1db0e122cfc18ea07958ddebea5d9a3.tar.bz2 |
qemu-config: fix memory leak on ferror()
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>
-rw-r--r-- | util/qemu-config.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/util/qemu-config.c b/util/qemu-config.c index 7db810f..fdf6cd6 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; } |