lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230602-dax-region-put-v1-2-d8668f335d45@intel.com>
Date:   Fri, 02 Jun 2023 19:09:22 -0700
From:   ira.weiny@...el.com
To:     Dan Williams <dan.j.williams@...el.com>,
        Vishal Verma <vishal.l.verma@...el.com>,
        Dave Jiang <dave.jiang@...el.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Joao Martins <joao.m.martins@...cle.com>,
        Jonathan Cameron <Jonathan.Cameron@...wei.com>
Cc:     Yongqiang Liu <liuyongqiang13@...wei.com>,
        Paul Cassella <cassella@....com>, linux-kernel@...r.kernel.org,
        nvdimm@...ts.linux.dev, linux-cxl@...r.kernel.org,
        Ira Weiny <ira.weiny@...el.com>
Subject: [PATCH RFC 2/4] dax/hmem: Fix refcount leak in dax_hmem_probe()

From: Yongqiang Liu <liuyongqiang13@...wei.com>

We should always call dax_region_put() whenever devm_create_dev_dax()
succeed or fail to avoid refcount leak of dax_region. Move the return
value check after dax_region_put().

Cc: nvdimm@...ts.linux.dev
Fixes: c01044cc8191 ("ACPI: HMAT: refactor hmat_register_target_device to hmem_register_device")
Reviewed-by: Ira Weiny <ira.weiny@...el.com>
Signed-off-by: Yongqiang Liu <liuyongqiang13@...wei.com>
---
 drivers/dax/hmem/hmem.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/dax/hmem/hmem.c b/drivers/dax/hmem/hmem.c
index e5fe8b39fb94..b4831a3d3934 100644
--- a/drivers/dax/hmem/hmem.c
+++ b/drivers/dax/hmem/hmem.c
@@ -39,12 +39,10 @@ static int dax_hmem_probe(struct platform_device *pdev)
 		.size = region_idle ? 0 : range_len(&mri->range),
 	};
 	dev_dax = devm_create_dev_dax(&data);
-	if (IS_ERR(dev_dax))
-		return PTR_ERR(dev_dax);
 
 	/* child dev_dax instances now own the lifetime of the dax_region */
 	dax_region_put(dax_region);
-	return 0;
+	return IS_ERR(dev_dax) ? PTR_ERR(dev_dax) : 0;
 }
 
 static struct platform_driver dax_hmem_driver = {

-- 
2.40.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ