qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] dump: fix use-after-free for s->fd
@ 2014-10-30  6:01 arei.gonglei
  2014-10-30  7:10 ` Markus Armbruster
  0 siblings, 1 reply; 11+ messages in thread
From: arei.gonglei @ 2014-10-30  6:01 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, armbru, Gonglei, peter.huangpeng, lcapitulino

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

After commit 4c7e251a (), when dump memory completed,
the s->fd will be closed twice. We should return
directly when dump completed.

Using do/while block, make the badly chosen return
values of get_next_block() more visible and fix
this issue.

Signed-off-by: Gonglei <arei.gonglei@huawei.com>
---
v2 -> v1:
Using do/while block, make the badly chosen return
values of get_next_block() more visible and fix
this issue. (Markus)
---
 dump.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/dump.c b/dump.c
index 06a4915..9c7dad8 100644
--- a/dump.c
+++ b/dump.c
@@ -604,10 +604,9 @@ static void dump_iterate(DumpState *s, Error **errp)
 {
     GuestPhysBlock *block;
     int64_t size;
-    int ret;
     Error *local_err = NULL;
 
-    while (1) {
+    do {
         block = s->next_block;
 
         size = block->target_end - block->target_start;
@@ -623,11 +622,9 @@ static void dump_iterate(DumpState *s, Error **errp)
             return;
         }
 
-        ret = get_next_block(s, block);
-        if (ret == 1) {
-            dump_completed(s);
-        }
-    }
+    } while (!get_next_block(s, block));
+
+    dump_completed(s);
 }
 
 static void create_vmcore(DumpState *s, Error **errp)
-- 
1.7.12.4

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

end of thread, other threads:[~2014-10-31 15:47 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-30  6:01 [Qemu-devel] [PATCH v2] dump: fix use-after-free for s->fd arei.gonglei
2014-10-30  7:10 ` Markus Armbruster
2014-10-30  7:33   ` zhanghailiang
2014-10-30  7:42   ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2014-10-30  9:23     ` Markus Armbruster
2014-10-30 10:50       ` Gonglei
2014-10-30 13:54   ` Michael Tokarev
2014-10-31  1:43     ` Gonglei
2014-10-31  7:18       ` Michael Tokarev
2014-10-31  7:40         ` Gonglei
2014-10-31  6:51     ` Markus Armbruster

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