diff mbox

savevm: Fix memory leak of compat struct

Message ID 20100721143509.4671.66441.stgit@localhost6.localdomain6
State New
Headers show

Commit Message

Alex Williamson July 21, 2010, 2:35 p.m. UTC
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(-)

Comments

Aurelien Jarno July 30, 2010, 9:01 p.m. UTC | #1
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);
>          }
>      }
> 
> 
>
diff mbox

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);
         }
     }