From patchwork Fri Feb 12 11:08:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harmandeep Kaur X-Patchwork-Id: 8290211 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 EDE51BEEE5 for ; Fri, 12 Feb 2016 11:11:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 26647203E1 for ; Fri, 12 Feb 2016 11:11:23 +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 512E4203DA for ; Fri, 12 Feb 2016 11:11:22 +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 1aUBar-0000nR-CN; Fri, 12 Feb 2016 11:08:57 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aUBap-0000nD-GA for xen-devel@lists.xenproject.org; Fri, 12 Feb 2016 11:08:55 +0000 Received: from [85.158.137.68] by server-3.bemta-3.messagelabs.com id 28/8E-02499-64DBDB65; Fri, 12 Feb 2016 11:08:54 +0000 X-Env-Sender: write.harmandeep@gmail.com X-Msg-Ref: server-6.tower-31.messagelabs.com!1455275332!21968017!1 X-Originating-IP: [209.85.220.65] 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 60824 invoked from network); 12 Feb 2016 11:08:54 -0000 Received: from mail-pa0-f65.google.com (HELO mail-pa0-f65.google.com) (209.85.220.65) by server-6.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 12 Feb 2016 11:08:54 -0000 Received: by mail-pa0-f65.google.com with SMTP id yy13so3698669pab.1 for ; Fri, 12 Feb 2016 03:08:54 -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=OZF8YQ4HS+T+zGYvis+6yftgELG7/EJfX4RKN9hN4ck=; b=BnaBsl7wVObOog/Y11aGU+haUr14autk6P9DSP9ygInNlxQzNEmAGhwS8zg/VLqD9F g2CYMEGYnS0zUZYGmsi0oaaBvoZQgHmMl9hWN4uga3YGIVsbw2thCJtsbtyJL1qzireN 9zThjwBOoegwCJ/BbUL5eO6avlHzMPOrluCFSiJxm68jTnyxFyI4E9Ek7OkIZPR6kyNl HsDCv+oj0ctjZU9clIJu144ThOcg5mL0Tgy6CiBVi6gUgxoAtCkSbRiZYInHKFUyCqLO 7VQYfeBMGu4KgLP/v24XWnJH7Zfw8fhxMQD8SoKRDCInk6+ZryYCfprwXJ+glNTufK0Z xglA== 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=OZF8YQ4HS+T+zGYvis+6yftgELG7/EJfX4RKN9hN4ck=; b=H642WJ1DcGTNS6UgoxcTLC9xDdsqDW63XXRTYxt1RYbDnoTVoJ6LDiaMrCSx4xlxSw QRXTeLNxczaHWnVK/J+HXfvrlFN4U30L3L9daTR8GfC08l5xoR3IsvVEcewRQsItHDkd /T4/bUiSQGA0M4B5RIPBmwxp9OoRbMM2CiGqEsD0JHSzyFXRq6L/I/lmUgf37/ab0HFe Kglx//EcJKqbOX7j84hcwOVkt7N9iWoqq+vfFb2DB+XtIsVdp2U5Sl+zb2bXC2IpU8Eh oQS81BHxxSbf+f3Y9hdeaq+7Mb+uqO+7sVh8EENhWrVPWp0bzErKfJyQe2eQq9uG4A31 EFag== X-Gm-Message-State: AG10YOTnaFLXeRnbHJhSKPc4dLP+ymYwqJRp/rHU6ORtwyt4r4kq7Ie18w9dislcDSBHnQ== X-Received: by 10.66.63.68 with SMTP id e4mr1193351pas.134.1455275332644; Fri, 12 Feb 2016 03:08:52 -0800 (PST) Received: from localhost.localdomain ([124.253.93.110]) by smtp.googlemail.com with ESMTPSA id r77sm18670247pfa.47.2016.02.12.03.08.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Feb 2016 03:08:52 -0800 (PST) From: Harmandeep Kaur To: xen-devel@lists.xenproject.org Date: Fri, 12 Feb 2016 16:38:32 +0530 Message-Id: <1455275312-3515-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 v3] 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 Acked-by: Wei Liu --- v2: call to unmapping function reduced to one from two v3: passed correct argument sysctl.u.tbuf_op.size in xenforeignmemory_unmap() --- 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..283fbd1 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, sysctl.u.tbuf_op.size); - return 0; + return rc; } int xc_tbuf_enable(xc_interface *xch, unsigned long pages, unsigned long *mfn,