From patchwork Wed Feb 3 10:59:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 8200371 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 58078BEEE5 for ; Wed, 3 Feb 2016 11:03:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6C5B620260 for ; Wed, 3 Feb 2016 11:03:06 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A684C201C0 for ; Wed, 3 Feb 2016 11:03:04 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aQvAe-000805-Qo; Wed, 03 Feb 2016 11:00:24 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aQvAd-0007zz-DY for xen-devel@lists.xenproject.org; Wed, 03 Feb 2016 11:00:23 +0000 Received: from [85.158.143.35] by server-1.bemta-4.messagelabs.com id A9/9A-09708-6CDD1B65; Wed, 03 Feb 2016 11:00:22 +0000 X-Env-Sender: prvs=8342f37c0=roger.pau@citrix.com X-Msg-Ref: server-14.tower-21.messagelabs.com!1454497215!13712962!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 45551 invoked from network); 3 Feb 2016 11:00:21 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-14.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 3 Feb 2016 11:00:21 -0000 X-IronPort-AV: E=Sophos;i="5.22,389,1449532800"; d="scan'208";a="329375213" From: Roger Pau Monne To: Date: Wed, 3 Feb 2016 11:59:57 +0100 Message-ID: <1454497197-2134-1-git-send-email-roger.pau@citrix.com> X-Mailer: git-send-email 2.5.4 (Apple Git-61) In-Reply-To: <1454495951.25207.52.camel@citrix.com> References: <1454495951.25207.52.camel@citrix.com> MIME-Version: 1.0 X-DLP: MIA1 Cc: Wei Liu , Ian Jackson , Ian Campbell , Roger Pau Monne Subject: [Xen-devel] [PATCH] libxc: fix leak in xc_dom_load_hvm_kernel error path X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Error path in xc_dom_load_hvm_kernel needs to use the 'error' label instead of directly returning. This is needed so the entries local variable is freed. Coverity-ID: 1351227 Signed-off-by: Roger Pau Monné --- Cc: Ian Jackson Cc: Ian Campbell Cc: Wei Liu --- tools/libxc/xc_dom_hvmloader.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/libxc/xc_dom_hvmloader.c b/tools/libxc/xc_dom_hvmloader.c index 79a3b99..330d5e8 100644 --- a/tools/libxc/xc_dom_hvmloader.c +++ b/tools/libxc/xc_dom_hvmloader.c @@ -257,7 +257,7 @@ static elf_errorstatus xc_dom_load_hvm_kernel(struct xc_dom_image *dom) if ( rc < 0 ) { DOMPRINTF("%s: failed to load elf binary", __func__); - return rc; + goto error; } munmap(elf->dest_base, elf->dest_size); @@ -267,14 +267,14 @@ static elf_errorstatus xc_dom_load_hvm_kernel(struct xc_dom_image *dom) if ( rc != 0 ) { DOMPRINTF("%s: insufficient space to load modules.", __func__); - return rc; + goto error; } rc = loadmodules(dom, m_start, m_end, dom->guest_domid); if ( rc != 0 ) { DOMPRINTF("%s: unable to load modules.", __func__); - return rc; + goto error; } dom->parms.phys_entry = elf_uval(elf, elf->ehdr, e_entry);