qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] spice: fix memory leak
@ 2015-02-11 16:50 Gerd Hoffmann
  2015-02-12  2:14 ` Gonglei
  0 siblings, 1 reply; 8+ messages in thread
From: Gerd Hoffmann @ 2015-02-11 16:50 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>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
---
 monitor.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/monitor.c b/monitor.c
index c3cc060..2c37953 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(err);
             return -1;
         }
 
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [Qemu-devel] [PATCH v2] spice: fix memory leak
@ 2014-12-05  8:30 arei.gonglei
  2014-12-05 12:56 ` Eric Blake
  2014-12-08  9:25 ` Gerd Hoffmann
  0 siblings, 2 replies; 8+ messages in thread
From: arei.gonglei @ 2014-12-05  8:30 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() 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>
---
v2: 
 - using assert() instead of returning NULL. (Gerd)
 - fix some typos. (Eric)
 - add Eric's R-by tag, hope Eric has no objection
   because of changes of v2. :)
---
 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 6467fa4..1100f8e 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -386,10 +386,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.7.12.4

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

end of thread, other threads:[~2015-02-12  2:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-11 16:50 [Qemu-devel] [PATCH v2] spice: fix memory leak Gerd Hoffmann
2015-02-12  2:14 ` Gonglei
  -- strict thread matches above, loose matches on Subject: below --
2014-12-05  8:30 arei.gonglei
2014-12-05 12:56 ` Eric Blake
2014-12-08  0:07   ` Gonglei
2014-12-08  9:25 ` Gerd Hoffmann
2014-12-08  9:31   ` Stefan Weil
2014-12-08 11:42     ` Gerd Hoffmann

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