From patchwork Mon Jun 26 18:52:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 9810337 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 0D5D5603D7 for ; Mon, 26 Jun 2017 18:59:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C24926256 for ; Mon, 26 Jun 2017 18:59:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0104628479; Mon, 26 Jun 2017 18:59:24 +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=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9AFEC26256 for ; Mon, 26 Jun 2017 18:59:24 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id D1BB121A00ACB; Mon, 26 Jun 2017 11:57:54 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 694252095A6D4 for ; Mon, 26 Jun 2017 11:57:53 -0700 (PDT) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP; 26 Jun 2017 11:59:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,397,1493708400"; d="scan'208";a="117648671" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.125]) by orsmga005.jf.intel.com with ESMTP; 26 Jun 2017 11:59:22 -0700 Subject: [ndctl PATCH] ndctl, check-namespace: fix resource leak From: Dan Williams To: linux-nvdimm@lists.01.org Date: Mon, 26 Jun 2017 11:52:56 -0700 Message-ID: <149850317639.1029.4272990186528265578.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.17.1-9-g687f MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Static analysis points out that we leak 'bttc' in namespace_check(). Cc: Vishal Verma Signed-off-by: Dan Williams --- ndctl/check.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ndctl/check.c b/ndctl/check.c index 3775c2ed4a3a..2d913cf5a4c2 100644 --- a/ndctl/check.c +++ b/ndctl/check.c @@ -898,7 +898,8 @@ int namespace_check(struct ndctl_namespace *ndns, struct check_opts *opts) if (sigaction(SIGBUS, &act, 0)) { err(bttc, "Unable to set sigaction\n"); - return -errno; + rc = -errno; + goto out_bttc; } bttc->opts = opts; @@ -912,7 +913,7 @@ int namespace_check(struct ndctl_namespace *ndns, struct check_opts *opts) if (opts->force) { rc = ndctl_namespace_disable_safe(ndns); if (rc) - return rc; + goto out_bttc; disabled_flag = 1; } else { err(bttc, "%s: check aborted, namespace online\n",