svn commit: r315934 - head/sys/x86/iommu

Konstantin Belousov kib at FreeBSD.org
Sat Mar 25 10:47:36 UTC 2017


Author: kib
Date: Sat Mar 25 10:47:35 2017
New Revision: 315934
URL: https://svnweb.freebsd.org/changeset/base/315934

Log:
  Avoid leaking allocated but unused context after creation race.
  
  As noted in the comment, nothing special needs to be done to destroy
  the unneeded context after the allocation race, but the context memory
  itself still should to be freed.
  
  Sponsored by:	The FreeBSD Foundation
  MFC after:	1 week

Modified:
  head/sys/x86/iommu/intel_ctx.c

Modified: head/sys/x86/iommu/intel_ctx.c
==============================================================================
--- head/sys/x86/iommu/intel_ctx.c	Sat Mar 25 10:45:16 2017	(r315933)
+++ head/sys/x86/iommu/intel_ctx.c	Sat Mar 25 10:47:35 2017	(r315934)
@@ -472,13 +472,15 @@ dmar_get_ctx_for_dev(struct dmar_unit *d
 			    dmar->unit, dmar->segment, bus, slot,
 			    func, rid, domain->domain, domain->mgaw,
 			    domain->agaw, id_mapped ? "id" : "re");
+			dmar_unmap_pgtbl(sf);
 		} else {
-			/* Nothing needs to be done to destroy ctx1. */
+			dmar_unmap_pgtbl(sf);
 			dmar_domain_destroy(domain1);
+			/* Nothing needs to be done to destroy ctx1. */
+			free(ctx1, M_DMAR_CTX);
 			domain = ctx->domain;
 			ctx->refs++; /* tag referenced us */
 		}
-		dmar_unmap_pgtbl(sf);
 	} else {
 		domain = ctx->domain;
 		ctx->refs++; /* tag referenced us */


More information about the svn-src-all mailing list