From: Ira Weiny <ira.weiny@intel.com>
To: Li Zhijian <lizhijian@fujitsu.com>, <dave@stgolabs.net>,
<jonathan.cameron@huawei.com>, <dave.jiang@intel.com>,
<alison.schofield@intel.com>, <vishal.l.verma@intel.com>,
<ira.weiny@intel.com>, <dan.j.williams@intel.com>,
<linux-cxl@vger.kernel.org>
Cc: <linux-kernel@vger.kernel.org>, Li Zhijian <lizhijian@fujitsu.com>
Subject: Re: [PATCH] cxl/region: Fix memregion leaks in devm_cxl_add_region()
Date: Mon, 29 Apr 2024 09:23:01 -0700 [thread overview]
Message-ID: <662fc9659f6ab_19ca3929435@iweiny-mobl.notmuch> (raw)
In-Reply-To: <20240428053715.327444-1-lizhijian@fujitsu.com>
Li Zhijian wrote:
> Move memregion_free(id) out of cxl_region_alloc() and
> explicately free memregion in devm_cxl_add_region() error path.
^^^^
explicitly
BTW you should run checkpatch.pl which will check spelling.
I'm not following what the problem is you are trying to fix. This seems
like it just moves the memregion_free() around a bit but the logic is the
same.
Ira
>
> After cxl_region_alloc() succeed, memregion will be freed by
> cxl_region_type.release()
>
> Fixes: 6e099264185d ("cxl/region: Add volatile region creation support")
> Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
> ---
> drivers/cxl/core/region.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index 812b2948b6c6..8535718a20f0 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -2250,10 +2250,8 @@ static struct cxl_region *cxl_region_alloc(struct cxl_root_decoder *cxlrd, int i
> struct device *dev;
>
> cxlr = kzalloc(sizeof(*cxlr), GFP_KERNEL);
> - if (!cxlr) {
> - memregion_free(id);
> + if (!cxlr)
> return ERR_PTR(-ENOMEM);
> - }
>
> dev = &cxlr->dev;
> device_initialize(dev);
> @@ -2358,12 +2356,15 @@ static struct cxl_region *devm_cxl_add_region(struct cxl_root_decoder *cxlrd,
> break;
> default:
> dev_err(&cxlrd->cxlsd.cxld.dev, "unsupported mode %d\n", mode);
> + memregion_free(id);
> return ERR_PTR(-EINVAL);
> }
>
> cxlr = cxl_region_alloc(cxlrd, id);
> - if (IS_ERR(cxlr))
> + if (IS_ERR(cxlr)) {
> + memregion_free(id);
> return cxlr;
> + }
> cxlr->mode = mode;
> cxlr->type = type;
>
> --
> 2.29.2
>
next prev parent reply other threads:[~2024-04-29 16:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-28 5:37 [PATCH] cxl/region: Fix memregion leaks in devm_cxl_add_region() Li Zhijian
2024-04-29 16:23 ` Ira Weiny [this message]
[not found] ` <TY1PR01MB1562E0A5EA4F95FFE0F39602A51F2@TY1PR01MB1562.jpnprd01.prod.outlook.com>
2024-05-03 16:07 ` Dan Williams
2024-05-07 5:28 ` Zhijian Li (Fujitsu)
2024-05-07 2:42 ` Zhijian Li (Fujitsu)
2024-05-07 15:52 ` Dave Jiang
2024-05-09 3:11 ` Zhijian Li (Fujitsu)
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=662fc9659f6ab_19ca3929435@iweiny-mobl.notmuch \
--to=ira.weiny@intel.com \
--cc=alison.schofield@intel.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=dave@stgolabs.net \
--cc=jonathan.cameron@huawei.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizhijian@fujitsu.com \
--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