From: Ira Weiny <ira.weiny@intel.com>
To: Yongqiang Liu <liuyongqiang13@huawei.com>
Cc: <linux-kernel@vger.kernel.org>, <nvdimm@lists.linux.dev>,
<dan.j.williams@intel.com>, <vishal.l.verma@intel.com>,
<dave.jiang@intel.com>, <akpm@linux-foundation.org>,
<joao.m.martins@oracle.com>, <zhangxiaoxu5@huawei.com>
Subject: Re: [PATCH] dax/hmem: Fix refcount leak in dax_hmem_probe()
Date: Sat, 3 Dec 2022 12:49:16 -0800 [thread overview]
Message-ID: <Y4u2TK4yPU9dfiDr@iweiny-mobl> (raw)
In-Reply-To: <20221203095858.612027-1-liuyongqiang13@huawei.com>
On Sat, Dec 03, 2022 at 09:58:58AM +0000, Yongqiang Liu wrote:
> 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().
I think dax_region_put is called from dax_region_unregister() automatically on
tear down.
>
> Fixes: c01044cc8191 ("ACPI: HMAT: refactor hmat_register_target_device to hmem_register_device")
I'm also not sure how this patch is related to this fix.
Ira
> Signed-off-by: Yongqiang Liu <liuyongqiang13@huawei.com>
> ---
> drivers/dax/hmem/hmem.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/dax/hmem/hmem.c b/drivers/dax/hmem/hmem.c
> index 1bf040dbc834..09f5cd7b6c8e 100644
> --- a/drivers/dax/hmem/hmem.c
> +++ b/drivers/dax/hmem/hmem.c
> @@ -36,12 +36,11 @@ static int dax_hmem_probe(struct platform_device *pdev)
> .size = region_idle ? 0 : resource_size(res),
> };
> 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 int dax_hmem_remove(struct platform_device *pdev)
> --
> 2.25.1
>
>
next prev parent reply other threads:[~2022-12-03 20:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-03 9:58 [PATCH] dax/hmem: Fix refcount leak in dax_hmem_probe() Yongqiang Liu
2022-12-03 20:49 ` Ira Weiny [this message]
2022-12-06 9:17 ` Yongqiang Liu
2023-06-02 2:31 ` Paul Cassella
2023-06-02 18:43 ` Ira Weiny
2023-06-02 21:11 ` Paul Cassella
2023-06-02 23:34 ` Ira Weiny
2023-06-03 4:11 ` Dan Williams
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=Y4u2TK4yPU9dfiDr@iweiny-mobl \
--to=ira.weiny@intel.com \
--cc=akpm@linux-foundation.org \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=joao.m.martins@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=liuyongqiang13@huawei.com \
--cc=nvdimm@lists.linux.dev \
--cc=vishal.l.verma@intel.com \
--cc=zhangxiaoxu5@huawei.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