From: ira.weiny@intel.com
To: Dan Williams <dan.j.williams@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
Dave Jiang <dave.jiang@intel.com>,
Andrew Morton <akpm@linux-foundation.org>,
Joao Martins <joao.m.martins@oracle.com>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Yongqiang Liu <liuyongqiang13@huawei.com>,
Paul Cassella <cassella@hpe.com>,
linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev,
linux-cxl@vger.kernel.org, Ira Weiny <ira.weiny@intel.com>
Subject: [PATCH RFC 2/4] dax/hmem: Fix refcount leak in dax_hmem_probe()
Date: Fri, 02 Jun 2023 19:09:22 -0700 [thread overview]
Message-ID: <20230602-dax-region-put-v1-2-d8668f335d45@intel.com> (raw)
In-Reply-To: <20230602-dax-region-put-v1-0-d8668f335d45@intel.com>
From: Yongqiang Liu <liuyongqiang13@huawei.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@lists.linux.dev
Fixes: c01044cc8191 ("ACPI: HMAT: refactor hmat_register_target_device to hmem_register_device")
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Yongqiang Liu <liuyongqiang13@huawei.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
next prev parent reply other threads:[~2023-06-03 2:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-03 2:09 [PATCH RFC 0/4] dax: Clean up dax_region references Ira Weiny
2023-06-03 2:09 ` [PATCH RFC 1/4] dax/bus: Fix leaked reference in alloc_dax_region() Ira Weiny
2023-06-03 2:09 ` ira.weiny [this message]
2023-06-03 2:09 ` [PATCH RFC 3/4] dax/cxl: Fix refcount leak in cxl_dax_region_probe() Ira Weiny
2023-06-03 2:09 ` [PATCH RFC 4/4] dax/bus: Remove unnecessary reference in alloc_dax_region() Ira Weiny
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230602-dax-region-put-v1-2-d8668f335d45@intel.com \
--to=ira.weiny@intel.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=cassella@hpe.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=joao.m.martins@oracle.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liuyongqiang13@huawei.com \
--cc=nvdimm@lists.linux.dev \
--cc=vishal.l.verma@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).