From: Avi Kivity Date: Sat, 30 Dec 2006 00:49:58 +0000 (-0800) Subject: [PATCH] KVM: Fix oops on oom X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=55a54f79e091d52c3c2835985c347ea4d2e1c21f;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git [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 0e618bcfe1da..973544553cba 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); }