From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gonglei <arei.gonglei@huawei.com>,
Gerd Hoffmann <kraxel@redhat.com>,
Anthony Liguori <aliguori@amazon.com>
Subject: [Qemu-devel] [PULL 6/6] spice: fix memory leak
Date: Tue, 16 Dec 2014 15:13:37 +0100 [thread overview]
Message-ID: <1418739217-6561-7-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1418739217-6561-1-git-send-email-kraxel@redhat.com>
From: Gonglei <arei.gonglei@huawei.com>
If errors happen for middle items of channel_list,
qmp_query_spice_channels() returns NULL, and the variable
cur_item going out of scope leaks the storage it points to.
The flag is a compatibility thing for older spice-server
versions. Meanwhile our minimum spice version requirement is
new enough that we should never ever see this error, and if we
do something went very seriously wrong. Let's using assert()
instead of returning NULL to avoid a memory leak.
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
ui/spice-core.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/ui/spice-core.c b/ui/spice-core.c
index 497670c..fe705c1 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -385,10 +385,7 @@ static SpiceChannelList *qmp_query_spice_channels(void)
struct sockaddr *paddr;
socklen_t plen;
- if (!(item->info->flags & SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT)) {
- error_report("invalid channel event");
- return NULL;
- }
+ assert(item->info->flags & SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT);
chan = g_malloc0(sizeof(*chan));
chan->value = g_malloc0(sizeof(*chan->value));
--
1.8.3.1
next prev parent reply other threads:[~2014-12-16 14:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-16 14:13 [Qemu-devel] [PULL 0/6] spice patch queue Gerd Hoffmann
2014-12-16 14:13 ` [Qemu-devel] [PULL 1/6] spice: use bottom half instead of refresh timer for cursor updates Gerd Hoffmann
2014-12-16 14:13 ` [Qemu-devel] [PULL 2/6] spice: reduce refresh rate in native mode Gerd Hoffmann
2014-12-16 14:13 ` [Qemu-devel] [PULL 3/6] spice: rework mirror allocation, add no-resize fast path Gerd Hoffmann
2014-12-16 14:13 ` [Qemu-devel] [PULL 4/6] spice: do not require TCP ports Gerd Hoffmann
2014-12-16 14:13 ` [Qemu-devel] [PULL 5/6] spice: remove spice-experimental.h include Gerd Hoffmann
2014-12-16 14:13 ` Gerd Hoffmann [this message]
2014-12-17 16:23 ` [Qemu-devel] [PULL 0/6] spice patch queue Peter Maydell
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=1418739217-6561-7-git-send-email-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=aliguori@amazon.com \
--cc=arei.gonglei@huawei.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).