Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 May 2014 17:14:58 GMT
From:      mihai@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r268865 - soc2014/mihai/bhyve-icache-head/sys/amd64/vmm
Message-ID:  <201405301714.s4UHEwmv055564@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mihai
Date: Fri May 30 17:14:58 2014
New Revision: 268865
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=268865

Log:
  sys: amd64: vmm: vmm_instruction_cache.c: fix memory leak

Modified:
  soc2014/mihai/bhyve-icache-head/sys/amd64/vmm/vmm_instruction_cache.c

Modified: soc2014/mihai/bhyve-icache-head/sys/amd64/vmm/vmm_instruction_cache.c
==============================================================================
--- soc2014/mihai/bhyve-icache-head/sys/amd64/vmm/vmm_instruction_cache.c	Fri May 30 16:53:53 2014	(r268864)
+++ soc2014/mihai/bhyve-icache-head/sys/amd64/vmm/vmm_instruction_cache.c	Fri May 30 17:14:58 2014	(r268865)
@@ -151,12 +151,12 @@
 	struct vie_cached *vie_cached;
 	int hash;
 
-	vie_cached = malloc(sizeof(struct vie_cached), M_VIECACHED, M_WAITOK | M_ZERO);
-
 	/* Check to see if caching is enabled */
 	if (!vmm_cached_instruction_enable)
 		return (0);
 
+	vie_cached = malloc(sizeof(struct vie_cached), M_VIECACHED, M_WAITOK | M_ZERO);
+
 	vie_cached->vm = vm;
 	vie_cached->rip = rip;
 	vie_cached->cr3 = cr3;
@@ -205,12 +205,14 @@
 {
 	struct vie_cached *vie_cached;
 	int hash;
-	uint64_t rip_page = trunc_page(rip);
+	uint64_t rip_page;
 
 	/* Check to see if caching is enabled */
 	if (!vmm_cached_instruction_enable)
 		return (0);
 
+	rip_page = trunc_page(rip);
+
 	hash = jenkins_hash(&vm, sizeof(struct vm *), 0) & VIE_CACHE_HASH_MASK;
 
 	rm_wlock(&vie_cached_hash[hash].vie_cached_lock);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201405301714.s4UHEwmv055564>