diff mbox

[29/37] ipmi: free extern timer

Message ID 20160719085432.4572-30-marcandre.lureau@redhat.com
State New
Headers show

Commit Message

Marc-André Lureau July 19, 2016, 8:54 a.m. UTC
From: Marc-André Lureau <marcandre.lureau@redhat.com>

Free the timer allocated during instance init.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/ipmi/ipmi_bmc_extern.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Corey Minyard July 21, 2016, 1:05 p.m. UTC | #1
I believe this is correct:

Reviewed-by: Corey Minyard <cminyard@mvista.com>

I looked around at other devices with timers, I found several (two 
watchdogs, and ipmi_bmc_sim.c, for instance) that allocate the timer in 
the realize function but don't deallocate it in the unrealize function.  
Do those need to be fixed, too?

-corey


On 07/19/2016 03:54 AM, marcandre.lureau@redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> Free the timer allocated during instance init.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>   hw/ipmi/ipmi_bmc_extern.c | 9 +++++++++
>   1 file changed, 9 insertions(+)
>
> diff --git a/hw/ipmi/ipmi_bmc_extern.c b/hw/ipmi/ipmi_bmc_extern.c
> index 157879e..5b73983 100644
> --- a/hw/ipmi/ipmi_bmc_extern.c
> +++ b/hw/ipmi/ipmi_bmc_extern.c
> @@ -487,6 +487,14 @@ static void ipmi_bmc_extern_init(Object *obj)
>       vmstate_register(NULL, 0, &vmstate_ipmi_bmc_extern, ibe);
>   }
>   
> +static void ipmi_bmc_extern_finalize(Object *obj)
> +{
> +    IPMIBmcExtern *ibe = IPMI_BMC_EXTERN(obj);
> +
> +    timer_del(ibe->extern_timer);
> +    timer_free(ibe->extern_timer);
> +}
> +
>   static Property ipmi_bmc_extern_properties[] = {
>       DEFINE_PROP_CHR("chardev", IPMIBmcExtern, chr),
>       DEFINE_PROP_END_OF_LIST(),
> @@ -508,6 +516,7 @@ static const TypeInfo ipmi_bmc_extern_type = {
>       .parent        = TYPE_IPMI_BMC,
>       .instance_size = sizeof(IPMIBmcExtern),
>       .instance_init = ipmi_bmc_extern_init,
> +    .instance_finalize = ipmi_bmc_extern_finalize,
>       .class_init    = ipmi_bmc_extern_class_init,
>    };
>
Marc-Andre Lureau July 21, 2016, 1:10 p.m. UTC | #2
Hi

----- Original Message -----
> I believe this is correct:
> 
> Reviewed-by: Corey Minyard <cminyard@mvista.com>
> 
> I looked around at other devices with timers, I found several (two
> watchdogs, and ipmi_bmc_sim.c, for instance) that allocate the timer in
> the realize function but don't deallocate it in the unrealize function.
> Do those need to be fixed, too?

Yes, I haven't found them myself, but I can include fixes in the series too.

thanks

> 
> -corey
> 
> 
> On 07/19/2016 03:54 AM, marcandre.lureau@redhat.com wrote:
> > From: Marc-André Lureau <marcandre.lureau@redhat.com>
> >
> > Free the timer allocated during instance init.
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> >   hw/ipmi/ipmi_bmc_extern.c | 9 +++++++++
> >   1 file changed, 9 insertions(+)
> >
> > diff --git a/hw/ipmi/ipmi_bmc_extern.c b/hw/ipmi/ipmi_bmc_extern.c
> > index 157879e..5b73983 100644
> > --- a/hw/ipmi/ipmi_bmc_extern.c
> > +++ b/hw/ipmi/ipmi_bmc_extern.c
> > @@ -487,6 +487,14 @@ static void ipmi_bmc_extern_init(Object *obj)
> >       vmstate_register(NULL, 0, &vmstate_ipmi_bmc_extern, ibe);
> >   }
> >   
> > +static void ipmi_bmc_extern_finalize(Object *obj)
> > +{
> > +    IPMIBmcExtern *ibe = IPMI_BMC_EXTERN(obj);
> > +
> > +    timer_del(ibe->extern_timer);
> > +    timer_free(ibe->extern_timer);
> > +}
> > +
> >   static Property ipmi_bmc_extern_properties[] = {
> >       DEFINE_PROP_CHR("chardev", IPMIBmcExtern, chr),
> >       DEFINE_PROP_END_OF_LIST(),
> > @@ -508,6 +516,7 @@ static const TypeInfo ipmi_bmc_extern_type = {
> >       .parent        = TYPE_IPMI_BMC,
> >       .instance_size = sizeof(IPMIBmcExtern),
> >       .instance_init = ipmi_bmc_extern_init,
> > +    .instance_finalize = ipmi_bmc_extern_finalize,
> >       .class_init    = ipmi_bmc_extern_class_init,
> >    };
> >   
> 
>
diff mbox

Patch

diff --git a/hw/ipmi/ipmi_bmc_extern.c b/hw/ipmi/ipmi_bmc_extern.c
index 157879e..5b73983 100644
--- a/hw/ipmi/ipmi_bmc_extern.c
+++ b/hw/ipmi/ipmi_bmc_extern.c
@@ -487,6 +487,14 @@  static void ipmi_bmc_extern_init(Object *obj)
     vmstate_register(NULL, 0, &vmstate_ipmi_bmc_extern, ibe);
 }
 
+static void ipmi_bmc_extern_finalize(Object *obj)
+{
+    IPMIBmcExtern *ibe = IPMI_BMC_EXTERN(obj);
+
+    timer_del(ibe->extern_timer);
+    timer_free(ibe->extern_timer);
+}
+
 static Property ipmi_bmc_extern_properties[] = {
     DEFINE_PROP_CHR("chardev", IPMIBmcExtern, chr),
     DEFINE_PROP_END_OF_LIST(),
@@ -508,6 +516,7 @@  static const TypeInfo ipmi_bmc_extern_type = {
     .parent        = TYPE_IPMI_BMC,
     .instance_size = sizeof(IPMIBmcExtern),
     .instance_init = ipmi_bmc_extern_init,
+    .instance_finalize = ipmi_bmc_extern_finalize,
     .class_init    = ipmi_bmc_extern_class_init,
  };