From: "Jan Beulich" Subject: Re: [PATCH v3 1/2] amd/passthrough: Do not leak domain mappings from do_invalidate_dte() Date: Fri, 06 Dec 2013 08:37:50 +0000 Message-ID: <52A19AEE020000780010ABEC@nat28.tlf.novell.com> References: <529F6B3F020000780010A312@nat28.tlf.novell.com> <1386179995-2928-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Voqv5-0005XJ-QH for xen-devel@lists.xenproject.org; Fri, 06 Dec 2013 08:37:56 +0000 In-Reply-To: <1386179995-2928-1-git-send-email-andrew.cooper3@citrix.com> Content-Disposition: inline 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 Cc: xen-devel , Keir Fraser , Suravee Suthikulpanit List-Id: xen-devel@lists.xenproject.org >>> On 04.12.13 at 18:59, Andrew Cooper wrote: > Coverity ID: 1135379 > > As the code stands, the domain mapping will be leaked on each error path. > > The mapping can be for a much shorter period of time, and all the relevent > information can be pulled out at once. > > Signed-off-by: Andrew Cooper > CC: Keir Fraser Reviewed-by: Jan Beulich > CC: Suravee Suthikulpanit > > --- > > Changes in v3: > * Dont break the pointer arithmatic on gdte > --- > xen/drivers/passthrough/amd/iommu_guest.c | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/xen/drivers/passthrough/amd/iommu_guest.c > b/xen/drivers/passthrough/amd/iommu_guest.c > index 952600a..c1fa0ff 100644 > --- a/xen/drivers/passthrough/amd/iommu_guest.c > +++ b/xen/drivers/passthrough/amd/iommu_guest.c > @@ -430,6 +430,10 @@ static int do_invalidate_dte(struct domain *d, > cmd_entry_t *cmd) > > gdom_id = get_domid_from_dte(gdte); > gcr3_gfn = get_guest_cr3_from_dte(gdte); > + glx = get_glx_from_dte(gdte); > + gv = get_gv_from_dte(gdte); > + > + unmap_domain_page(gdte); > > /* Do not update host dte before gcr3 has been set */ > if ( gcr3_gfn == 0 ) > @@ -449,11 +453,6 @@ static int do_invalidate_dte(struct domain *d, > cmd_entry_t *cmd) > return -ENODEV; > } > > - glx = get_glx_from_dte(gdte); > - gv = get_gv_from_dte(gdte); > - > - unmap_domain_page(dte_base); > - > /* Setup host device entry */ > hdom_id = host_domid(d, gdom_id); > req_id = get_dma_requestor_id(iommu->seg, mbdf); > -- > 1.7.10.4