Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753126AbdF0NIp (ORCPT ); Tue, 27 Jun 2017 09:08:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:63353 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752721AbdF0NIg (ORCPT ); Tue, 27 Jun 2017 09:08:36 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 610702B0A81 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=pbonzini@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 610702B0A81 Subject: Re: [PATCH v1 1/1] KVM: add missing kvm_put_kvm in case of failure To: Claudio Imbrenda , kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, borntraeger@de.ibm.com, frankja@linux.vnet.ibm.com, viro@ZenIV.linux.org.uk References: <1498564636-20259-1-git-send-email-imbrenda@linux.vnet.ibm.com> From: Paolo Bonzini Message-ID: <66c8737e-20f7-627f-a1dd-8139d3304959@redhat.com> Date: Tue, 27 Jun 2017 15:08:32 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: <1498564636-20259-1-git-send-email-imbrenda@linux.vnet.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 27 Jun 2017 13:08:35 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1078 Lines: 35 On 27/06/2017 13:57, Claudio Imbrenda wrote: > If I'm not missing anything, in case kvm_create_vm_debugfs fails, we > will have a memory leak due to not freeing the kvm object. > > A call to kvm_put_kvm was accidentally removed from an error handling in > commit 506cfba9e726 ("KVM: don't use anon_inode_getfd() before possible failures") > > This patch simply restores the call to kvm_put_kvm, so that the kvm > object is destroyed before returning an error. > > Signed-off-by: Claudio Imbrenda > Fixes: 506cfba9e726 ("KVM: don't use anon_inode_getfd() before possible failures") > --- > virt/kvm/kvm_main.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index f0fe9d0..257d2a8 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -3194,6 +3194,7 @@ static int kvm_dev_ioctl_create_vm(unsigned long type) > if (kvm_create_vm_debugfs(kvm, r) < 0) { > put_unused_fd(r); > fput(file); > + kvm_put_kvm(kvm); > return -ENOMEM; > } > > Queued, thanks. Paolo