From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52953) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ujztr-0004DV-GN for qemu-devel@nongnu.org; Tue, 04 Jun 2013 18:40:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ujztq-0007FU-L8 for qemu-devel@nongnu.org; Tue, 04 Jun 2013 18:40:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:21950) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ujztq-0007FK-DE for qemu-devel@nongnu.org; Tue, 04 Jun 2013 18:40:18 -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.14.4/8.14.4) with ESMTP id r54MeEdN009246 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 4 Jun 2013 18:40:16 -0400 Message-ID: <51AE6CC0.4050808@redhat.com> Date: Wed, 05 Jun 2013 00:40:00 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1370371954-8479-1-git-send-email-pbonzini@redhat.com> <1370371954-8479-12-git-send-email-pbonzini@redhat.com> <20130604220328.GB30400@redhat.com> In-Reply-To: <20130604220328.GB30400@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 11/39] msix: split msix_free from msix_uninit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: qemu-devel@nongnu.org Il 05/06/2013 00:03, Michael S. Tsirkin ha scritto: >> > + if (dev->msix_table || dev->msix_pba || dev->msix_entry_used) { >> > + msix_free(dev); >> > + } >> > + >> > dev->msix_table = g_malloc0(table_size); >> > dev->msix_pba = g_malloc0(pba_size); >> > dev->msix_entry_used = g_malloc0(nentries * sizeof *dev->msix_entry_used); > Wow msix_init calls msix_free, and not on error path? > What's going on here? I wasn't too sure that you could get here only with NULL msix_table/pba/entry_used and wanted to protect against leaks. I'll change it to an assertion. >> > @@ -359,16 +363,26 @@ void msix_uninit(PCIDevice *dev, MemoryRegion *table_bar, MemoryRegion *pba_bar) >> > msix_free_irq_entries(dev); >> > dev->msix_entries_nr = 0; >> > memory_region_del_subregion(pba_bar, &dev->msix_pba_mmio); >> > - memory_region_destroy(&dev->msix_pba_mmio); >> > - g_free(dev->msix_pba); >> > - dev->msix_pba = NULL; >> > memory_region_del_subregion(table_bar, &dev->msix_table_mmio); >> > - memory_region_destroy(&dev->msix_table_mmio); >> > - g_free(dev->msix_table); >> > + dev->cap_present &= ~QEMU_PCI_CAP_MSIX; >> > +} >> > + >> > +void msix_free(PCIDevice *dev) >> > +{ >> > + if (dev->msix_pba) { >> > + memory_region_destroy(&dev->msix_pba_mmio); >> > + g_free(dev->msix_pba); >> > + } >> > + dev->msix_pba = NULL; >> > + >> > + if (dev->msix_table) { >> > + memory_region_destroy(&dev->msix_table_mmio); >> > + g_free(dev->msix_table); >> > + } >> > dev->msix_table = NULL; >> > + >> > g_free(dev->msix_entry_used); >> > dev->msix_entry_used = NULL; >> > - dev->cap_present &= ~QEMU_PCI_CAP_MSIX; >> > } >> > >> > void msix_uninit_exclusive_bar(PCIDevice *dev) > As long as we had init and uninit, it was mostly > self-documenting. > Now, there are two cleanup functions, so please add documentation. Yes, will do. Paolo