Patchwork savevm: Fix memory leak of compat struct

login
register
mail settings
Submitter Alex Williamson
Date July 21, 2010, 2:35 p.m.
Message ID <20100721143509.4671.66441.stgit@localhost6.localdomain6>
Download mbox | patch
Permalink /patch/59445/
State New
Headers show

Comments

Alex Williamson - July 21, 2010, 2:35 p.m.
Forgot to check for and free these.

Found-by: Zachary Amsden <zamsden@redhat.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---

 0.13 Candidate

 savevm.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
Aurelien Jarno - July 30, 2010, 9:01 p.m.
On Wed, Jul 21, 2010 at 08:35:31AM -0600, Alex Williamson wrote:
> Forgot to check for and free these.
> 
> Found-by: Zachary Amsden <zamsden@redhat.com>
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> ---
> 
>  0.13 Candidate
> 
>  savevm.c |    6 ++++++
>  1 files changed, 6 insertions(+), 0 deletions(-)

Thanks, applied.

> diff --git a/savevm.c b/savevm.c
> index ee27989..1612794 100644
> --- a/savevm.c
> +++ b/savevm.c
> @@ -1126,6 +1126,9 @@ void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque)
>      QTAILQ_FOREACH_SAFE(se, &savevm_handlers, entry, new_se) {
>          if (strcmp(se->idstr, id) == 0 && se->opaque == opaque) {
>              QTAILQ_REMOVE(&savevm_handlers, se, entry);
> +            if (se->compat) {
> +                qemu_free(se->compat);
> +            }
>              qemu_free(se);
>          }
>      }
> @@ -1193,6 +1196,9 @@ void vmstate_unregister(DeviceState *dev, const VMStateDescription *vmsd,
>      QTAILQ_FOREACH_SAFE(se, &savevm_handlers, entry, new_se) {
>          if (se->vmsd == vmsd && se->opaque == opaque) {
>              QTAILQ_REMOVE(&savevm_handlers, se, entry);
> +            if (se->compat) {
> +                qemu_free(se->compat);
> +            }
>              qemu_free(se);
>          }
>      }
> 
> 
>

Patch

diff --git a/savevm.c b/savevm.c
index ee27989..1612794 100644
--- a/savevm.c
+++ b/savevm.c
@@ -1126,6 +1126,9 @@  void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque)
     QTAILQ_FOREACH_SAFE(se, &savevm_handlers, entry, new_se) {
         if (strcmp(se->idstr, id) == 0 && se->opaque == opaque) {
             QTAILQ_REMOVE(&savevm_handlers, se, entry);
+            if (se->compat) {
+                qemu_free(se->compat);
+            }
             qemu_free(se);
         }
     }
@@ -1193,6 +1196,9 @@  void vmstate_unregister(DeviceState *dev, const VMStateDescription *vmsd,
     QTAILQ_FOREACH_SAFE(se, &savevm_handlers, entry, new_se) {
         if (se->vmsd == vmsd && se->opaque == opaque) {
             QTAILQ_REMOVE(&savevm_handlers, se, entry);
+            if (se->compat) {
+                qemu_free(se->compat);
+            }
             qemu_free(se);
         }
     }