From patchwork Tue Jul 12 09:38:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Shuo X-Patchwork-Id: 9224883 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DEADF604DB for ; Tue, 12 Jul 2016 09:39:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CEF1A27C39 for ; Tue, 12 Jul 2016 09:39:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C391527EED; Tue, 12 Jul 2016 09:39:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B2E127C39 for ; Tue, 12 Jul 2016 09:39:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932421AbcGLJip (ORCPT ); Tue, 12 Jul 2016 05:38:45 -0400 Received: from mga04.intel.com ([192.55.52.120]:61975 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932392AbcGLJio (ORCPT ); Tue, 12 Jul 2016 05:38:44 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP; 12 Jul 2016 02:38:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,351,1464678000"; d="scan'208";a="1015222721" Received: from shuo.sh.intel.com (HELO localhost) ([10.239.154.220]) by orsmga002.jf.intel.com with ESMTP; 12 Jul 2016 02:38:41 -0700 From: Liu Shuo To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Zhang Yanmin , He Bo , Liu Shuo , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Subject: [PATCH] KVM: release anon file in failure path of vm creation Date: Tue, 12 Jul 2016 17:38:42 +0800 Message-Id: <1468316323-23835-1-git-send-email-shuo.a.liu@intel.com> X-Mailer: git-send-email 1.9.4 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The failure of create debugfs of VM will return directly without release the anon file. It will leak memory and file descriptors, even through be not serious. Signed-off-by: Liu Shuo --- virt/kvm/kvm_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 48bd520..8322154 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -49,6 +49,7 @@ #include #include #include +#include #include #include @@ -3067,6 +3068,7 @@ static int kvm_dev_ioctl_create_vm(unsigned long type) if (kvm_create_vm_debugfs(kvm, r) < 0) { kvm_put_kvm(kvm); + sys_close(r); return -ENOMEM; }