From a930a09bb175124647787ffed8355d3152cb5e2d Mon Sep 17 00:00:00 2001 From: Amit Shah Date: Fri, 14 Feb 2014 07:50:10 +0100 Subject: [PATCH] monitor: Cleanup mon->outbuf on write error RH-Author: Amit Shah Message-id: Patchwork-id: 57271 O-Subject: [RHEL 6.6, 6.5.z qemu-kvm PATCH 1/1] monitor: Cleanup mon->outbuf on write error Bugzilla: 1060024 RH-Acked-by: Markus Armbruster RH-Acked-by: Laszlo Ersek RH-Acked-by: Luiz Capitulino From: Stratos Psomadakis In case monitor_flush() fails to write the contents of mon->outbuf to the output device, mon->outbuf is not cleaned up properly. Check the return code of the qemu_chr_fe_write() function and cleanup the outbuf if it fails. References: http://lists.nongnu.org/archive/html/qemu-devel/2014-01/msg02890.html Bugzilla: 1060024 Signed-off-by: Stratos Psomadakis Signed-off-by: Dimitris Aragiorgis Signed-off-by: Luiz Capitulino (cherry picked from commit 056f49ff2cf645dc484956b00b65a3aa18a1a9a3) Signed-off-by: Amit Shah --- monitor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) Signed-off-by: Miroslav Rezanina --- monitor.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/monitor.c b/monitor.c index 9152293..72ac865 100644 --- a/monitor.c +++ b/monitor.c @@ -290,8 +290,8 @@ void monitor_flush(Monitor *mon) if (len && !mon->mux_out) { rc = qemu_chr_fe_write(mon->chr, (const uint8_t *) buf, len); - if (rc == len) { - /* all flushed */ + if ((rc < 0 && errno != EAGAIN) || (rc == len)) { + /* all flushed or error */ QDECREF(mon->outbuf); mon->outbuf = qstring_new(); return; -- 1.7.1