]> err.no Git - linux-2.6/commitdiff
[PATCH] KVM: Fix oops on oom
authorAvi Kivity <avi@qumranet.com>
Sat, 30 Dec 2006 00:49:58 +0000 (16:49 -0800)
committerLinus Torvalds <torvalds@woody.osdl.org>
Sat, 30 Dec 2006 18:56:44 +0000 (10:56 -0800)
__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 <avi@qumranet.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
drivers/kvm/kvm_main.c

index 0e618bcfe1dad5076f431ec8c412fd43f1cbb22c..973544553cba1434fc878c8754f00b5e6cfa2129 100644 (file)
@@ -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);
                }