Skip to contentSkip to conversation

serial: fix memory leak in serial exit

PATCH In review Li Qiang 3 participants 4 messages Jan 4, 2017 – Jan 5, 2017

lore
Share & tools
lore

Li Qiang

author
#0 lore raw

PATCH 1/1 serial: fix memory leak in serial exit

From: Li Qiang <[email protected]>

The serial_exit_core function doesn't free some resources. This can lead memory leak when hotplug and unplug. This patch avoid this.

---
 hw/char/serial.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
hw/char/serial.c +10 -0
index ffbacd8..67b18ed 100644
@@ -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);
 }
 
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 23 lines · Li Qiang

From: Li Qiang <[email protected]>

The serial_exit_core function doesn't free some resources. This can lead memory leak when hotplug and unplug. This patch avoid this.

---
 hw/char/serial.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
hw/char/serial.c +3 -0
index ffbacd8..67b18ed 100644
@@ -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);

hw/char/serial.c void serial_realize_core(SerialState *s, Error **errp) · line 921

Quoted 10 lines
hw/char/serial.c +7 -0
+
+    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);
 }
 

Thanks, looks good.

Paolo

#2 lore raw
Quoted 39 lines · Paolo Bonzini
Quoted 23 lines · Li Qiang

From: Li Qiang <[email protected]>

The serial_exit_core function doesn't free some resources. This can lead memory leak when hotplug and unplug. This patch avoid this.

---
 hw/char/serial.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
hw/char/serial.c +3 -0
index ffbacd8..67b18ed 100644
@@ -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);

hw/char/serial.c void serial_realize_core(SerialState *s, Error **errp) · line 921

Quoted 10 lines
hw/char/serial.c +7 -0
+
+    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);
 }
 

Thanks, looks good.

Quoted 1 line

Paolo

Paolo, so are you merging this?

Signature · 1 line
MST
#3 lore raw
Quoted 40 lines · Michael S. Tsirkin
Quoted 39 lines · Paolo Bonzini
Quoted 23 lines · Li Qiang

From: Li Qiang <[email protected]>

The serial_exit_core function doesn't free some resources. This can lead memory leak when hotplug and unplug. This patch avoid this.

---
 hw/char/serial.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
hw/char/serial.c +3 -0
index ffbacd8..67b18ed 100644
@@ -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);

hw/char/serial.c void serial_realize_core(SerialState *s, Error **errp) · line 921

Quoted 10 lines
hw/char/serial.c +7 -0
+
+    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);
 }
 

Thanks, looks good.

Quoted 6 lines
Quoted 1 line

Paolo

Paolo, so are you merging this?

Yes, thanks.

Paolo