summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaolo Bonzini2016-01-18 11:25:45 +0100
committerPaolo Bonzini2016-01-26 15:58:11 +0100
commit27ef9cb0e77eda46618ea084adffa63ebde5be80 (patch)
tree883091ccb15f807bfd1f6290364cdd7c2c71fcf3
parentdocs: Style the command and its options in the synopsis (diff)
downloadqemu-27ef9cb0e77eda46618ea084adffa63ebde5be80.tar.gz
qemu-27ef9cb0e77eda46618ea084adffa63ebde5be80.tar.xz
qemu-27ef9cb0e77eda46618ea084adffa63ebde5be80.zip
qemu-char: avoid leak in qemu_chr_open_pp_fd
drv leaks if qemu_chr_alloc returns an error. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--qemu-char.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/qemu-char.c b/qemu-char.c
index b9e5547ce1..ca53e8c376 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -1740,18 +1740,19 @@ static CharDriverState *qemu_chr_open_pp_fd(int fd,
return NULL;
}
- drv = g_new0(ParallelCharDriver, 1);
- drv->fd = fd;
- drv->mode = IEEE1284_MODE_COMPAT;
-
chr = qemu_chr_alloc(backend, errp);
if (!chr) {
return NULL;
}
+
+ drv = g_new0(ParallelCharDriver, 1);
+ chr->opaque = drv;
chr->chr_write = null_chr_write;
chr->chr_ioctl = pp_ioctl;
chr->chr_close = pp_close;
- chr->opaque = drv;
+
+ drv->fd = fd;
+ drv->mode = IEEE1284_MODE_COMPAT;
return chr;
}