From: Avi Kivity Date: Sat, 30 Dec 2006 00:49:58 +0000 (-0800) Subject: [PATCH] KVM: Fix oops on oom X-Git-Tag: v2.6.20-rc3~11 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=55a54f79e091d52c3c2835985c347ea4d2e1c21f;p=linux-2.6 [PATCH] KVM: Fix oops on oom __free_page() doesn't like a NULL argument, so check before calling it. A NULL can only happen if memory is exhausted during allocation of a memory slot. Signed-off-by: Avi Kivity Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index 0e618bcfe1..973544553c 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c @@ -245,7 +245,8 @@ static void kvm_free_physmem_slot(struct kvm_memory_slot *free, if (!dont || free->phys_mem != dont->phys_mem) if (free->phys_mem) { for (i = 0; i < free->npages; ++i) - __free_page(free->phys_mem[i]); + if (free->phys_mem[i]) + __free_page(free->phys_mem[i]); vfree(free->phys_mem); }