From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 2/2] KVM: Fix kvm_free_physmem_slot memory leak. Date: Thu, 06 Nov 2008 17:14:18 +0200 Message-ID: <491309CA.8030605@redhat.com> References: <6ad07c640810280208i40152f59i8b92269be8224c67@mail.gmail.com> <6ad07c640810280257q5cc7f425rccd01617a9347c3b@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: kvm@vger.kernel.org To: =?UTF-8?B?RnJhbsOnb2lzIERpYWtoYXRl?= Return-path: Received: from mx2.redhat.com ([66.187.237.31]:36988 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751368AbYKFPOX (ORCPT ); Thu, 6 Nov 2008 10:14:23 -0500 In-Reply-To: <6ad07c640810280257q5cc7f425rccd01617a9347c3b@mail.gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: (late reply, sorry) =46ran=C3=A7ois Diakhate wrote: > [Sorry, I realized I forgot to check style, here is the fixed patch] > > Make sure that kvm_free_physmem_slot also frees the VM memory > if it was allocated by the kernel. > > /* > * Free any memory in @free but not in @dont. > */ > -static void kvm_free_physmem_slot(struct kvm_memory_slot *free, > +static void kvm_free_physmem_slot(struct kvm *kvm, > + struct kvm_memory_slot *free, > struct kvm_memory_slot *dont) > { > + if (!dont || free->userspace_addr !=3D dont->userspace_addr) { > + struct kvm_userspace_memory_region mem =3D { > + .slot =3D memslot_id(kvm, free), > + .guest_phys_addr =3D free->base_gfn << PAGE_SHIFT, > + .memory_size =3D 0, > + .flags =3D 0, > + }; > + kvm_arch_set_memory_region(kvm, &mem, *free, free->user_alloc); > + } > + > if (!dont || free->rmap !=3D dont->rmap) > =20 What happens here if the both free and dont have nonzero, differnt=20 ->userspace_addr values? Is is even possible? Also, the call chain is fishy. set_memory_region calls=20 free_physmem_slot which calls arch_set_memory_region. This is turning=20 into pasta. --=20 error compiling committee.c: too many arguments to function