qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] serial: fix memory leak in serial exit
@ 2017-01-04  8:43 Li Qiang
  2017-01-04 11:43 ` Paolo Bonzini
  0 siblings, 1 reply; 4+ messages in thread
From: Li Qiang @ 2017-01-04  8:43 UTC (permalink / raw)
  To: mst, pbonzini, qemu-devel; +Cc: Li Qiang

From: Li Qiang <liqiang6-s@360.cn>

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>
---
 hw/char/serial.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/hw/char/serial.c b/hw/char/serial.c
index ffbacd8..67b18ed 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);
 }
 
-- 
1.8.3.1

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

* Re: [Qemu-devel] [PATCH] serial: fix memory leak in serial exit
  2017-01-04  8:43 [Qemu-devel] [PATCH] serial: fix memory leak in serial exit Li Qiang
@ 2017-01-04 11:43 ` Paolo Bonzini
  2017-01-04 13:24   ` Michael S. Tsirkin
  0 siblings, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2017-01-04 11:43 UTC (permalink / raw)
  To: Li Qiang, mst, qemu-devel; +Cc: Li Qiang



On 04/01/2017 09:43, Li Qiang wrote:
> From: Li Qiang <liqiang6-s@360.cn>
> 
> 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>
> ---
>  hw/char/serial.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/hw/char/serial.c b/hw/char/serial.c
> index ffbacd8..67b18ed 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);
>  }
>  
> 

Thanks, looks good.

Paolo

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

* Re: [Qemu-devel] [PATCH] serial: fix memory leak in serial exit
  2017-01-04 11:43 ` Paolo Bonzini
@ 2017-01-04 13:24   ` Michael S. Tsirkin
  2017-01-05 10:17     ` Paolo Bonzini
  0 siblings, 1 reply; 4+ messages in thread
From: Michael S. Tsirkin @ 2017-01-04 13:24 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Li Qiang, qemu-devel, Li Qiang

On Wed, Jan 04, 2017 at 12:43:35PM +0100, Paolo Bonzini wrote:
> 
> 
> On 04/01/2017 09:43, Li Qiang wrote:
> > From: Li Qiang <liqiang6-s@360.cn>
> > 
> > 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>
> > ---
> >  hw/char/serial.c | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
> > 
> > diff --git a/hw/char/serial.c b/hw/char/serial.c
> > index ffbacd8..67b18ed 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);
> >  }
> >  
> > 
> 
> Thanks, looks good.
> 
> Paolo


Paolo, so are you merging this?

Acked-by: Michael S. Tsirkin <mst@redhat.com>
-- 
MST

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

* Re: [Qemu-devel] [PATCH] serial: fix memory leak in serial exit
  2017-01-04 13:24   ` Michael S. Tsirkin
@ 2017-01-05 10:17     ` Paolo Bonzini
  0 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2017-01-05 10:17 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: Li Qiang, qemu-devel, Li Qiang



On 04/01/2017 14:24, Michael S. Tsirkin wrote:
> On Wed, Jan 04, 2017 at 12:43:35PM +0100, Paolo Bonzini wrote:
>>
>>
>> On 04/01/2017 09:43, Li Qiang wrote:
>>> From: Li Qiang <liqiang6-s@360.cn>
>>>
>>> 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>
>>> ---
>>>  hw/char/serial.c | 10 ++++++++++
>>>  1 file changed, 10 insertions(+)
>>>
>>> diff --git a/hw/char/serial.c b/hw/char/serial.c
>>> index ffbacd8..67b18ed 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);
>>>  }
>>>  
>>>
>>
>> Thanks, looks good.
>>
>> Paolo
> 
> 
> Paolo, so are you merging this?
> 
> Acked-by: Michael S. Tsirkin <mst@redhat.com>

Yes, thanks.

Paolo

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

end of thread, other threads:[~2017-01-05 10:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-04  8:43 [Qemu-devel] [PATCH] serial: fix memory leak in serial exit Li Qiang
2017-01-04 11:43 ` Paolo Bonzini
2017-01-04 13:24   ` Michael S. Tsirkin
2017-01-05 10:17     ` Paolo Bonzini

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