aboutsummaryrefslogtreecommitdiff
path: root/hw/char/serial.c
diff options
context:
space:
mode:
authorLi Qiang <liqiang6-s@360.cn>2017-01-04 00:43:16 -0800
committerPaolo Bonzini <pbonzini@redhat.com>2017-01-16 17:52:35 +0100
commit8409dc884a201bf74b30a9d232b6bbdd00cb7e2b (patch)
treee15cc272c850bffad649624e15cdf42a9d512d16 /hw/char/serial.c
parent1f8af0d186abf9ef775a74d41bf2852ed8d59b63 (diff)
serial: fix memory leak in serial exit
The serial_exit_core function doesn't free some resources. This can lead memory leak when hotplug and unplug. This patch avoid this. Signed-off-by: Li Qiang <liqiang6-s@360.cn> Message-Id: <586cb5ab.f31d9d0a.38ac3.acf2@mx.google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/char/serial.c')
-rw-r--r--hw/char/serial.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/hw/char/serial.c b/hw/char/serial.c
index ffbacd8227..67b18eda12 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -906,6 +906,16 @@ void serial_realize_core(SerialState *s, Error **errp)
void serial_exit_core(SerialState *s)
{
qemu_chr_fe_deinit(&s->chr);
+
+ timer_del(s->modem_status_poll);
+ timer_free(s->modem_status_poll);
+
+ timer_del(s->fifo_timeout_timer);
+ timer_free(s->fifo_timeout_timer);
+
+ fifo8_destroy(&s->recv_fifo);
+ fifo8_destroy(&s->xmit_fifo);
+
qemu_unregister_reset(serial_reset, s);
}