From patchwork Thu Feb 11 08:32:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harmandeep Kaur X-Patchwork-Id: 8277131 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 96D559F4DD for ; Thu, 11 Feb 2016 08:37:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C0E4720123 for ; Thu, 11 Feb 2016 08:37:51 +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 A27C220103 for ; Thu, 11 Feb 2016 08:37:50 +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 1aTmgi-0005z1-Uq; Thu, 11 Feb 2016 08:33:20 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aTmgh-0005yp-8f for xen-devel@lists.xenproject.org; Thu, 11 Feb 2016 08:33:19 +0000 Received: from [85.158.143.35] by server-3.bemta-4.messagelabs.com id AF/C5-31122-E474CB65; Thu, 11 Feb 2016 08:33:18 +0000 X-Env-Sender: write.harmandeep@gmail.com X-Msg-Ref: server-10.tower-21.messagelabs.com!1455179596!15142183!1 X-Originating-IP: [209.85.220.66] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 59643 invoked from network); 11 Feb 2016 08:33:18 -0000 Received: from mail-pa0-f66.google.com (HELO mail-pa0-f66.google.com) (209.85.220.66) by server-10.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 11 Feb 2016 08:33:18 -0000 Received: by mail-pa0-f66.google.com with SMTP id gc2so154237pab.0 for ; Thu, 11 Feb 2016 00:33:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=DbvmOQGtHsi2GoxCfPbuRCJQ14qVkr/Mtp4H5/MmpjI=; b=DHT82O9Bafhv6v/JbVEwQ39Xgsht3EECXueR+ADVPIurQWu0dq3CzxUaq1rG38aeKH Hirm/1YC0z8IQfiL1pwzjxBs5Mm2Chevv21wSfxGS/NM4Mw0iIEy010jmYbOn9kL7+Sd Y3nDSfeLHc7u+gkcrQw8742H3PV5UqD+Wf30sieAxFToe77xIf6n2PJJmsTykSbWDtzq yU/XIUigiWrSl964Zv5cNJxVbM7PRoMqaN660+HfhEjNP4Ib4219g9jSY+w/Kafvh0RP JUAVGBHogT+0e73t1bzhO/Aiiw9p5KtSCL8eN9haQAZd3ZmDYS/yBwfnCQ7fhoKE/VQe vHmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=DbvmOQGtHsi2GoxCfPbuRCJQ14qVkr/Mtp4H5/MmpjI=; b=XdOzl1ngp8p5F61JIb9RgzcQA134Onrvq5dE4YA9y9cla6meC7xOX3kImnuvYxdvtd cjM7K1OH7x93eCGE495ABwIg0TsJq9nGoyeiHSwceNYe4vH86HeU9RwuGvaHwYcTxGan pIDdkuu9Fh7B+giFTbkfBDOT8Bv9mXGl8qzKCASc2DLMNwmXps3rw/nhXFZAizhK1pAQ sqJQmb/cLCDJ0kh1FQYq6oWPRobKs0bxug+aZ8Jx2Xc0ymVIvtt3G81DKYMYhqJ7F6Wl dECbCp2kZbly7kLyzLNFXvPppCmFhOG3OAIVXJMKkgFyRafgrZDWMLfD1tX5h2bS7gnC Bhiw== X-Gm-Message-State: AG10YOSoY89Qk95qCULmmp7yxinHIXI6X5P2/61qd9S38+HPpwqKaodScX7SP8cmiQPzxg== X-Received: by 10.67.4.226 with SMTP id ch2mr61876087pad.116.1455179596670; Thu, 11 Feb 2016 00:33:16 -0800 (PST) Received: from localhost.localdomain ([124.253.95.243]) by smtp.googlemail.com with ESMTPSA id o73sm10370833pfa.37.2016.02.11.00.33.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Feb 2016 00:33:16 -0800 (PST) From: Harmandeep Kaur To: xen-devel@lists.xenproject.org Date: Thu, 11 Feb 2016 14:02:59 +0530 Message-Id: <1455179579-3476-1-git-send-email-write.harmandeep@gmail.com> X-Mailer: git-send-email 2.5.0 Cc: wei.liu2@citrix.com, ian.campbell@citrix.com, stefano.stabellini@eu.citrix.com, dario.faggioli@citrix.com, ian.jackson@eu.citrix.com, Harmandeep Kaur Subject: [Xen-devel] [PATCH v2] libxc: fix leak of t_info in xc_tbuf_get_size() 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: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, 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 Avoid leaking the memory mapping of the trace buffer Coverity ID 1351228 Signed-off-by: Harmandeep Kaur Reviewed-by: Dario Faggioli --- v2: call to unmapping function reduced to one from two --- tools/libxc/xc_tbuf.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/libxc/xc_tbuf.c b/tools/libxc/xc_tbuf.c index 695939a..d96cc67 100644 --- a/tools/libxc/xc_tbuf.c +++ b/tools/libxc/xc_tbuf.c @@ -70,11 +70,13 @@ int xc_tbuf_get_size(xc_interface *xch, unsigned long *size) sysctl.u.tbuf_op.buffer_mfn); if ( t_info == NULL || t_info->tbuf_size == 0 ) - return -1; + rc = -1; + else + *size = t_info->tbuf_size; - *size = t_info->tbuf_size; + xenforeignmemory_unmap(xch->fmem, t_info, *size); - return 0; + return rc; } int xc_tbuf_enable(xc_interface *xch, unsigned long pages, unsigned long *mfn,