[tip:tools/kvm] kvm tools, x86: Fix munmap() size in kvm__arch_delete_ram()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit-ID:  db748dc72be6322b4f9b0be6accb3cb863e43ee3
Gitweb:     http://git.kernel.org/tip/db748dc72be6322b4f9b0be6accb3cb863e43ee3
Author:     Pekka Enberg <penberg@xxxxxxxxxx>
AuthorDate: Sat, 4 Feb 2012 11:04:24 +0200
Committer:  Pekka Enberg <penberg@xxxxxxxxxx>
CommitDate: Sat, 4 Feb 2012 11:04:24 +0200

kvm tools, x86: Fix munmap() size in kvm__arch_delete_ram()

Sasha noticed during code review that commit e106906 ("kvm tool: Change
kvm->ram_size to real mapped size.") changed kvm->ram_size accounting to
include 32-bit memory hole but forgot to update munmap in
kvm__arch_delete_ram().

Reported-by: Sasha Levin <levinsasha928@xxxxxxxxx>
Signed-off-by: Pekka Enberg <penberg@xxxxxxxxxx>
---
 tools/kvm/x86/kvm.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/tools/kvm/x86/kvm.c b/tools/kvm/x86/kvm.c
index d6afa0210..10a1212 100644
--- a/tools/kvm/x86/kvm.c
+++ b/tools/kvm/x86/kvm.c
@@ -156,11 +156,11 @@ void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size)
 		die_perror("KVM_CREATE_PIT2 ioctl");
 
 	if (ram_size < KVM_32BIT_GAP_START) {
-        kvm->ram_size = ram_size;
+		kvm->ram_size = ram_size;
 		kvm->ram_start = mmap_anon_or_hugetlbfs(hugetlbfs_path, ram_size);
 	} else {
 		kvm->ram_start = mmap_anon_or_hugetlbfs(hugetlbfs_path, ram_size + KVM_32BIT_GAP_SIZE);
-        kvm->ram_size = ram_size + KVM_32BIT_GAP_SIZE;
+		kvm->ram_size = ram_size + KVM_32BIT_GAP_SIZE;
 		if (kvm->ram_start != MAP_FAILED)
 			/*
 			 * We mprotect the gap (see kvm__init_ram() for details) PROT_NONE so that
@@ -180,10 +180,7 @@ void kvm__arch_init(struct kvm *kvm, const char *hugetlbfs_path, u64 ram_size)
 
 void kvm__arch_delete_ram(struct kvm *kvm)
 {
-	if (kvm->ram_size < KVM_32BIT_GAP_START)
-		munmap(kvm->ram_start, kvm->ram_size);
-	else
-		munmap(kvm->ram_start, kvm->ram_size + KVM_32BIT_GAP_SIZE);
+	munmap(kvm->ram_start, kvm->ram_size);
 }
 
 void kvm__irq_line(struct kvm *kvm, int irq, int level)
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux