From patchwork Wed Feb 20 17:51:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukasz Plewa X-Patchwork-Id: 10822561 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 7846D13B5 for ; Wed, 20 Feb 2019 17:52:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6165D2F716 for ; Wed, 20 Feb 2019 17:52:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E7182F724; Wed, 20 Feb 2019 17:52:10 +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 E1EB72F728 for ; Wed, 20 Feb 2019 17:52:09 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id B6483211CC3A3; Wed, 20 Feb 2019 09:52:09 -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.126; helo=mga18.intel.com; envelope-from=lukasz.plewa@intel.com; receiver=linux-nvdimm@lists.01.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (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 DC27B211CBCFE for ; Wed, 20 Feb 2019 09:52:07 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Feb 2019 09:52:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,391,1544515200"; d="scan'208";a="135823617" Received: from lplewa-z170x-ud3.igk.intel.com ([10.91.124.122]) by orsmga002.jf.intel.com with ESMTP; 20 Feb 2019 09:52:06 -0800 From: Lukasz Plewa To: linux-nvdimm@lists.01.org Subject: [PATCH 1/1] ndctl: fix memory leak in libndctl Date: Wed, 20 Feb 2019 18:51:52 +0100 Message-Id: <20190220175152.25667-1-lukasz.plewa@intel.com> X-Mailer: git-send-email 2.17.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: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP From: Łukasz Plewa leak found by PMDK test suite: ==29103== 48 bytes in 4 blocks are definitely lost in loss record 3 of 3 ==29103== at 0x4C31C15: realloc (vg_replace_malloc.c:785) ==29103== by 0x5B76F74: parse_lbasize_supported.isra.11 (libndctl.c:4378) ==29103== by 0x5B78967: __add_pfn (libndctl.c:4830) ==29103== by 0x5B7FBEC: add_dax (libndctl.c:4882) ==29103== by 0x5B71959: __sysfs_device_parse (sysfs.c:118) ==29103== by 0x5B78683: device_parse (libndctl.c:725) ==29103== by 0x5B78683: daxs_init (libndctl.c:3833) ==29103== by 0x5B7FB6F: ndctl_dax_get_first (libndctl.c:5248) ==29103== by 0x5B80000: ndctl_namespace_get_dax (libndctl.c:3543) ==29103== by 0x4E4CA7E: os_dimm_region_namespace (os_dimm_ndctl.c:131) ==29103== by 0x4E4CD0D: os_dimm_interleave_set (os_dimm_ndctl.c:194) ==29103== by 0x4E4CE92: os_dimm_uid (os_dimm_ndctl.c:230) ==29103== by 0x4E5F632: shutdown_state_add_part (shutdown_state.c:112) Ref: pmem/issues#1020 Reported-by: Grzegorz Brzeziński Signed-off-by: Łukasz Plewa --- ndctl/lib/libndctl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ndctl/lib/libndctl.c b/ndctl/lib/libndctl.c index c9e2875..6de5463 100644 --- a/ndctl/lib/libndctl.c +++ b/ndctl/lib/libndctl.c @@ -518,6 +518,7 @@ static void __free_pfn(struct ndctl_pfn *pfn, struct list_head *head, void *to_f free(pfn->pfn_path); free(pfn->pfn_buf); free(pfn->bdev); + free(pfn->alignments.supported); free(to_free); }