From: sashiko-bot@kernel.org
To: "Dave Jiang" <dave.jiang@intel.com>
Cc: linux-cxl@vger.kernel.org
Subject: Re: [PATCH v5 2/6] cxl/test: Add type2 support for mock CFMWS0
Date: Thu, 11 Jun 2026 23:56:25 +0000 [thread overview]
Message-ID: <20260611235626.1E1BA1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260611234409.256765-3-dave.jiang@intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] alloc_mock_res() unconditionally dereferences `res` even if kzalloc() fails, and leaks `res` if gen_pool_alloc_algo() fails.
--
commit e10eed6f5b8f0ab41fd5d070bd75f2b5f0d1bef4
Author: Dave Jiang <dave.jiang@intel.com>
cxl/test: Add type2 support for mock CFMWS0
This commit adds a type2_test module parameter for triggering type 2 test
support in cxl_test. It also updates the CFMWS0 configuration to be type 2
when the parameter is set.
> diff --git a/tools/testing/cxl/test/cxl.c b/tools/testing/cxl/test/cxl.c
> index 1c8ac8bdd8f7a..c5529cee482d4 100644
> --- a/tools/testing/cxl/test/cxl.c
> +++ b/tools/testing/cxl/test/cxl.c
[ ... ]
> @@ -493,10 +512,14 @@ static int populate_cedt(void)
> chbs->length = size;
> }
>
> + if (type2_test)
> + update_type2_cfmws();
> +
> for (i = cfmws_start; i <= cfmws_end; i++) {
> struct acpi_cedt_cfmws *window = mock_cfmws[i];
>
> - cfmws_elc_update(window, i);
> + if (i == 0 && !type2_test)
> + cfmws_elc_update(window, i);
> res = alloc_mock_res(window->window_size, SZ_256M);
[Severity: High]
This is a pre-existing issue, but I noticed a potential problem in
alloc_mock_res() which is called here.
Does alloc_mock_res() unconditionally dereference the allocation before
checking for success? Looking at the function:
alloc_mock_res() {
struct cxl_mock_res *res = kzalloc(sizeof(*res), GFP_KERNEL);
...
INIT_LIST_HEAD(&res->list);
}
If kzalloc() returns NULL, won't INIT_LIST_HEAD() cause an immediate NULL
pointer dereference?
Additionally, if the subsequent memory pool allocation fails:
alloc_mock_res() {
...
phys = gen_pool_alloc_algo(cxl_mock_pool, size,
gen_pool_first_fit_align, &data);
if (!phys)
return NULL;
}
Does this leak the memory allocated for res by returning NULL without calling
kfree(res)?
> if (!res)
> return -ENOMEM;
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260611234409.256765-1-dave.jiang@intel.com?part=2
next prev parent reply other threads:[~2026-06-11 23:56 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-11 23:44 [PATCH v5 0/6] cxl: Add CXL type2 accelerator support for cxl_test Dave Jiang
2026-06-11 23:44 ` [PATCH v5 1/6] cxl/test: Add test for module parameters Dave Jiang
2026-06-11 23:59 ` sashiko-bot
2026-06-12 2:33 ` Richard Cheng
2026-06-12 15:35 ` Dave Jiang
2026-06-11 23:44 ` [PATCH v5 2/6] cxl/test: Add type2 support for mock CFMWS0 Dave Jiang
2026-06-11 23:56 ` sashiko-bot [this message]
2026-06-11 23:44 ` [PATCH v5 3/6] cxl/test: Refactor platform device enumerations Dave Jiang
2026-06-11 23:44 ` [PATCH v5 4/6] cxl/test: Add hierarchy enumeration support for type2 device Dave Jiang
2026-06-11 23:44 ` [PATCH v5 5/6] cxl/test: Fixup hdm init for auto region to support type2 Dave Jiang
2026-06-11 23:44 ` [PATCH v5 6/6] cxl/test: Add cxl_test accelerator driver Dave Jiang
2026-06-11 23:58 ` sashiko-bot
2026-06-12 2:44 ` Richard Cheng
2026-06-12 15:38 ` Dave Jiang
2026-06-17 14:24 ` Uwe Kleine-König
2026-06-17 17:28 ` Dave Jiang
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=20260611235626.1E1BA1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dave.jiang@intel.com \
--cc=linux-cxl@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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