]> Git Repo - qemu.git/commitdiff
qemu-config: fix memory leak on ferror()
authorPaolo Bonzini <[email protected]>
Mon, 5 Jul 2021 17:14:37 +0000 (19:14 +0200)
committerPaolo Bonzini <[email protected]>
Tue, 20 Jul 2021 15:06:28 +0000 (17:06 +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: [email protected]
Reported-by: Peter Maydell <[email protected]>
Fixes: f7544edcd3 ("qemu-config: add error propagation to qemu_config_parse", 2021-03-06)
Signed-off-by: Paolo Bonzini <[email protected]>
util/qemu-config.c

index 7db810f1e024a0c8ffc0bfb983165a1f9b42ca9b..fdf6cd69fcb78e14a18170a00cc14bf3accf199c 100644 (file)
@@ -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;
 }
This page took 0.024161 seconds and 4 git commands to generate.