qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] spice: fix memory leak
@ 2014-12-05  3:31 arei.gonglei
  2014-12-05  4:59 ` Eric Blake
  2014-12-05  7:17 ` Gerd Hoffmann
  0 siblings, 2 replies; 9+ messages in thread
From: arei.gonglei @ 2014-12-05  3:31 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, Gonglei, weidong.huang, kraxel

From: Gonglei <arei.gonglei@huawei.com>

If errors happen for middle items of channel_list,
qmp_query_spice_channels() return NULL, and varriable
cur_item going out of scope leaks the storage it points to.
Let's check for errors in advance avoid memory leak.

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
 ui/spice-core.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/ui/spice-core.c b/ui/spice-core.c
index 6467fa4..8a74afe 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -381,15 +381,17 @@ static SpiceChannelList *qmp_query_spice_channels(void)
     ChannelList *item;
 
     QTAILQ_FOREACH(item, &channel_list, link) {
-        SpiceChannelList *chan;
-        char host[NI_MAXHOST], port[NI_MAXSERV];
-        struct sockaddr *paddr;
-        socklen_t plen;
-
         if (!(item->info->flags & SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT)) {
             error_report("invalid channel event");
             return NULL;
         }
+    }
+
+    QTAILQ_FOREACH(item, &channel_list, link) {
+        SpiceChannelList *chan;
+        char host[NI_MAXHOST], port[NI_MAXSERV];
+        struct sockaddr *paddr;
+        socklen_t plen;
 
         chan = g_malloc0(sizeof(*chan));
         chan->value = g_malloc0(sizeof(*chan->value));
-- 
1.7.12.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread
* [Qemu-devel] [PATCH] spice: fix memory leak
@ 2015-02-11 16:44 Gerd Hoffmann
  2015-02-11 16:44 ` Paolo Bonzini
  2015-02-16  8:30 ` Michael Tokarev
  0 siblings, 2 replies; 9+ messages in thread
From: Gerd Hoffmann @ 2015-02-11 16:44 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, pbonzini, Gerd Hoffmann, Luiz Capitulino

Found by coverity.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 monitor.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/monitor.c b/monitor.c
index c3cc060..29d7e5b 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1101,6 +1101,7 @@ static int client_migrate_info(Monitor *mon, const QDict *qdict,
     if (strcmp(protocol, "spice") == 0) {
         if (!qemu_using_spice(&err)) {
             qerror_report_err(err);
+            error_free(local_err);
             return -1;
         }
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-02-16  8:30 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-05  3:31 [Qemu-devel] [PATCH] spice: fix memory leak arei.gonglei
2014-12-05  4:59 ` Eric Blake
2014-12-05  5:01   ` Gonglei
2014-12-05  7:17 ` Gerd Hoffmann
2014-12-05  7:22   ` Gonglei
2014-12-05  7:39     ` Gerd Hoffmann
  -- strict thread matches above, loose matches on Subject: below --
2015-02-11 16:44 Gerd Hoffmann
2015-02-11 16:44 ` Paolo Bonzini
2015-02-16  8:30 ` Michael Tokarev

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).