From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claudio Imbrenda Subject: [PATCH v1 1/1] KVM: add missing kvm_put_kvm in case of failure Date: Tue, 27 Jun 2017 13:57:16 +0200 Message-ID: <1498564636-20259-1-git-send-email-imbrenda@linux.vnet.ibm.com> Cc: linux-kernel@vger.kernel.org, borntraeger@de.ibm.com, frankja@linux.vnet.ibm.com, viro@ZenIV.linux.org.uk, pbonzini@redhat.com To: kvm@vger.kernel.org Return-path: Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:45563 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752892AbdF0L5X (ORCPT ); Tue, 27 Jun 2017 07:57:23 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v5RBs2HM088425 for ; Tue, 27 Jun 2017 07:57:22 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 2bbp8hhvv8-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 27 Jun 2017 07:57:22 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 27 Jun 2017 12:57:20 +0100 Sender: kvm-owner@vger.kernel.org List-ID: 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; } -- 2.7.4