From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59104) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UiOQv-0006Z2-Ou for qemu-devel@nongnu.org; Fri, 31 May 2013 08:27:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UiOQq-0006dz-O7 for qemu-devel@nongnu.org; Fri, 31 May 2013 08:27:49 -0400 Received: from mail-vb0-x236.google.com ([2607:f8b0:400c:c02::236]:54234) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UiOQq-0006dt-HN for qemu-devel@nongnu.org; Fri, 31 May 2013 08:27:44 -0400 Received: by mail-vb0-f54.google.com with SMTP id f13so978597vbg.41 for ; Fri, 31 May 2013 05:27:44 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <51A89733.40607@redhat.com> Date: Fri, 31 May 2013 14:27:31 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <20130530114604.4b12cb22@redhat.com> <51A77838.4060707@redhat.com> <20130530120832.5abe1c65@redhat.com> <51A8485A.4000605@linux.vnet.ibm.com> <51A85DE8.2090600@redhat.com> <51A864C2.8090904@linux.vnet.ibm.com> In-Reply-To: <51A864C2.8090904@linux.vnet.ibm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH uq/master] fix double free the memslot in kvm_set_phys_mem List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Xiao Guangrong Cc: Gleb Natapov , KVM , "Justen, Jordan L" , qemu-devel , Luiz Capitulino , Jordan Justen Il 31/05/2013 10:52, Xiao Guangrong ha scritto: > Luiz Capitulino reported that guest refused to boot and qemu > complained with: > kvm_set_phys_mem: error unregistering overlapping slot: Invalid argument > > It is caused by commit 235e8982ad that did double free for the memslot > so that the second one raises the -EINVAL error > > Fix it by reset memory size only if it is needed > > Reported-by: Luiz Capitulino > Signed-off-by: Xiao Guangrong > --- > kvm-all.c | 3 ++- > 1 files changed, 2 insertions(+), 1 deletions(-) > > diff --git a/kvm-all.c b/kvm-all.c > index 8e7bbf8..405480e 100644 > --- a/kvm-all.c > +++ b/kvm-all.c > @@ -206,7 +206,8 @@ static int kvm_set_user_memory_region(KVMState *s, KVMSlot *slot) > if (s->migration_log) { > mem.flags |= KVM_MEM_LOG_DIRTY_PAGES; > } > - if (mem.flags & KVM_MEM_READONLY) { > + > + if (slot->memory_size && mem.flags & KVM_MEM_READONLY) { > /* Set the slot size to 0 before setting the slot to the desired > * value. This is needed based on KVM commit 75d61fbc. */ > mem.memory_size = 0; > Reviewed-by: Paolo Bonzini