From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] qemu-char: avoid leak in qemu_chr_open_pp_fd
Date: Mon, 18 Jan 2016 11:25:51 +0100 [thread overview]
Message-ID: <1453112751-725-1-git-send-email-pbonzini@redhat.com> (raw)
drv leaks if qemu_chr_alloc returns an error.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
qemu-char.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/qemu-char.c b/qemu-char.c
index 9e2217b..2633b8a 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -1778,18 +1778,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;
}
--
2.5.0
next reply other threads:[~2016-01-18 10:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-18 10:25 Paolo Bonzini [this message]
2016-01-18 10:38 ` [Qemu-devel] [PATCH] qemu-char: avoid leak in qemu_chr_open_pp_fd Daniel P. Berrange
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1453112751-725-1-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).