From patchwork Wed Jan 30 23:13:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Verma, Vishal L" X-Patchwork-Id: 10789367 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A07D7746 for ; Wed, 30 Jan 2019 23:13:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B75EF2FA9C for ; Wed, 30 Jan 2019 23:13:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB6E22FAA1; Wed, 30 Jan 2019 23:13:20 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 6E4E42FA9C for ; Wed, 30 Jan 2019 23:13:20 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 19D07211C2806; Wed, 30 Jan 2019 15:13:20 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.20; helo=mga02.intel.com; envelope-from=vishal.l.verma@intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 B22D9211BA47B for ; Wed, 30 Jan 2019 15:13:18 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Jan 2019 15:13:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,542,1539673200"; d="scan'208";a="316290810" Received: from vverma7-desk1.lm.intel.com ([10.232.112.170]) by fmsmga005.fm.intel.com with ESMTP; 30 Jan 2019 15:13:17 -0800 From: Vishal Verma To: Subject: [ndctl PATCH] libndctl: fix bb iterator leak in namespaces Date: Wed, 30 Jan 2019 16:13:07 -0700 Message-Id: <20190130231307.5223-1-vishal.l.verma@intel.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Piotr Balcer Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP From: Piotr Balcer We were neglecting to free bb_iterator in free_namespace(), causing a memory leak. Close the leak by adding the required deallocation. Signed-off-by: Piotr Balcer Signed-off-by: Vishal Verma --- via github:pull/80 ndctl/lib/libndctl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c index 5eb915f..c9e2875 100644 --- a/ndctl/lib/libndctl.c +++ b/ndctl/lib/libndctl.c @@ -461,6 +461,7 @@ static void free_namespace(struct ndctl_namespace *ndns, struct list_head *head) free(ndns->ndns_buf); free(ndns->bdev); free(ndns->alt_name); + badblocks_iter_free(&ndns->bb_iter); kmod_module_unref(ndns->module); free(ndns); }