From mboxrd@z Thu Jan 1 00:00:00 1970 From: Suravee Suthikulpanit Subject: Re: [PATCH 2/4] AMD/iommu_detect: Don't leak iommu structure on error paths Date: Mon, 30 Dec 2013 00:39:16 +0700 Message-ID: <52C05E44.8060408@amd.com> References: <1388156253-14509-1-git-send-email-andrew.cooper3@citrix.com> <1388156253-14509-3-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1388156253-14509-3-git-send-email-andrew.cooper3@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andrew Cooper , Xen-devel Cc: Keir Fraser , Jan Beulich List-Id: xen-devel@lists.xenproject.org On 12/27/2013 09:57 PM, Andrew Cooper wrote: > Tweak the logic slightly to return the real errors from > get_iommu_{,msi_}capabilities(), which at the moment is no functional change. > > Coverity-ID: 1146950 > Signed-off-by: Andrew Cooper > CC: Keir Fraser > CC: Jan Beulich > CC: Suravee Suthikulpanit > --- > xen/drivers/passthrough/amd/iommu_detect.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/xen/drivers/passthrough/amd/iommu_detect.c b/xen/drivers/passthrough/amd/iommu_detect.c > index 6c10885..03003d7 100644 > --- a/xen/drivers/passthrough/amd/iommu_detect.c > +++ b/xen/drivers/passthrough/amd/iommu_detect.c > @@ -145,11 +145,11 @@ int __init amd_iommu_detect_one_acpi( > rt = get_iommu_capabilities(iommu->seg, bus, dev, func, > iommu->cap_offset, iommu); > if ( rt ) > - return -ENODEV; > + goto out; > > rt = get_iommu_msi_capabilities(iommu->seg, bus, dev, func, iommu); > if ( rt ) > - return -ENODEV; > + goto out; > > rt = pci_ro_device(iommu->seg, bus, PCI_DEVFN(dev, func)); > if ( rt ) > @@ -158,6 +158,11 @@ int __init amd_iommu_detect_one_acpi( > iommu->seg, bus, dev, func, rt); > > list_add_tail(&iommu->list, &amd_iommu_head); > + rt = 0; > > - return 0; > +out: > + if ( rt ) > + xfree(iommu); > + > + return rt; > } > Acked-by: Suravee Suthikulpanit