From patchwork Wed Jul 21 14:35:31 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 59445 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 992C5B70AF for ; Thu, 22 Jul 2010 00:36:58 +1000 (EST) Received: from localhost ([127.0.0.1]:48331 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ObaPm-000447-V3 for incoming@patchwork.ozlabs.org; Wed, 21 Jul 2010 10:36:54 -0400 Received: from [140.186.70.92] (port=33512 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ObaOX-0003mF-Vz for qemu-devel@nongnu.org; Wed, 21 Jul 2010 10:35:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1ObaOW-0001Ok-Pl for qemu-devel@nongnu.org; Wed, 21 Jul 2010 10:35:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25552) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1ObaOW-0001Oa-Hx for qemu-devel@nongnu.org; Wed, 21 Jul 2010 10:35:36 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o6LEZWvA021506 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 21 Jul 2010 10:35:33 -0400 Received: from localhost6.localdomain6 (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6LEZV4k025479; Wed, 21 Jul 2010 10:35:31 -0400 From: Alex Williamson To: qemu-devel@nongnu.org Date: Wed, 21 Jul 2010 08:35:31 -0600 Message-ID: <20100721143509.4671.66441.stgit@localhost6.localdomain6> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: alex.williamson@redhat.com, zamsden@redhat.com Subject: [Qemu-devel] [PATCH] savevm: Fix memory leak of compat struct X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Forgot to check for and free these. Found-by: Zachary Amsden Signed-off-by: Alex Williamson --- 0.13 Candidate savevm.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) 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); } }