From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44606) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VLs2q-0006BP-W9 for qemu-devel@nongnu.org; Tue, 17 Sep 2013 05:58:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VLs2k-00009t-WC for qemu-devel@nongnu.org; Tue, 17 Sep 2013 05:58:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32001) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VLs2k-00009o-OK for qemu-devel@nongnu.org; Tue, 17 Sep 2013 05:58:02 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r8H9w2Yq026145 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 17 Sep 2013 05:58:02 -0400 Message-ID: <523827B4.9020602@redhat.com> Date: Tue, 17 Sep 2013 11:58:12 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1378211609-16121-1-git-send-email-pbonzini@redhat.com> <1378211609-16121-24-git-send-email-pbonzini@redhat.com> <20130917092433.GD18186@redhat.com> In-Reply-To: <20130917092433.GD18186@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 23/38] shpc: split shpc_free from shpc_cleanup List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: qemu-devel@nongnu.org Il 17/09/2013 11:24, Michael S. Tsirkin ha scritto: >> @@ -630,15 +630,21 @@ int shpc_bar_size(PCIDevice *d) >> void shpc_cleanup(PCIDevice *d, MemoryRegion *bar) >> { >> SHPCDevice *shpc = d->shpc; >> + /* TODO: cleanup config space changes? */ >> d->cap_present &= ~QEMU_PCI_CAP_SHPC; >> memory_region_del_subregion(bar, &shpc->mmio); >> - /* TODO: cleanup config space changes? */ >> +} >> + >> +void shpc_free(PCIDevice *d) >> +{ >> + SHPCDevice *shpc = d->shpc; >> g_free(shpc->config); >> g_free(shpc->cmask); >> g_free(shpc->wmask); >> g_free(shpc->w1cmask); >> memory_region_destroy(&shpc->mmio); >> g_free(shpc); >> + d->shpc = NULL; I dislike having random dangling pointers. But it's not that bad if I move the clearing of QEMU_PCI_CAP_SHPC from shpc_cleanup to shpc_free. Paolo