Skip to contentSkip to conversation

savevm: Fix memory leak of compat struct

PATCH Applied Alex Williamson 2 participants 2 messages Jul 21, 2010 – Jul 30, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 savevm: Fix memory leak of compat struct

Forgot to check for and free these.

---

0.13 Candidate

 savevm.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
savevm.c +6 -0
index ee27989..1612794 100644
@@ -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);
         }
     }
#1 lore raw
Quoted 10 lines · Alex Williamson

Forgot to check for and free these.

---

0.13 Candidate

 savevm.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

Thanks, applied.

Quoted 27 lines
savevm.c +6 -0
index ee27989..1612794 100644
@@ -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);
         }
     }
Signature · 2 lines
Aurelien Jarno                          GPG: 1024D/F1BCDB73
[email protected]                 http://www.aurel32.net