From: sashiko-bot@kernel.org
To: "Dave Jiang" <dave.jiang@intel.com>
Cc: linux-cxl@vger.kernel.org
Subject: Re: [PATCH v6 3/6] cxl/test: Refactor platform device enumerations
Date: Mon, 29 Jun 2026 20:38:56 +0000 [thread overview]
Message-ID: <20260629203856.B13621F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260629202720.3658117-4-dave.jiang@intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Failure to assign an error code to `rc` (e.g., `-ENOMEM`) on device allocation failures in `cxl_test_init()`, `cxl_single_topo_init()`, and `cxl_rch_topo_init()`. This causes the functions to return `0` (success) or an uninitialized stack value on failure.
--
commit 49a38c246be39e985c66be86964ee186b899793d
Author: Dave Jiang <dave.jiang@intel.com>
cxl/test: Refactor platform device enumerations
Split all the host bridges, rootports, upstream and downstream ports
enumerations to separate helper functions. This should make adding
type2 hierarchy easier later on.
> diff --git a/tools/testing/cxl/test/cxl.c b/tools/testing/cxl/test/cxl.c
> index 32964420e470a..8abe066080bc8 100644
> --- a/tools/testing/cxl/test/cxl.c
> +++ b/tools/testing/cxl/test/cxl.c
[ ... ]
> @@ -1868,62 +1868,34 @@ static bool __init have_multiple_modparms(void)
[ ... ]
> +static int host_bridges_populate(void)
> +{
> + int rc = 0;
>
> - for (i = 0; i < ARRAY_SIZE(cxl_host_bridge); i++) {
> + for (int i = 0; i < ARRAY_SIZE(cxl_host_bridge); i++) {
> struct acpi_device *adev = &host_bridge[i];
> struct platform_device *pdev;
>
> pdev = platform_device_alloc("cxl_host_bridge", i);
> - if (!pdev)
> + if (!pdev) {
> + rc = -ENOMEM;
> goto err_bridge;
> + }
[Severity: High]
This is a pre-existing issue, but I see you fixed the missing rc = -ENOMEM
assignments during failure paths in this newly refactored function and others.
However, does the same missing rc = -ENOMEM assignment still exist in
other unrefactored topology initialization functions in
tools/testing/cxl/test/cxl.c?
For example, in cxl_single_topo_init():
pdev = platform_device_alloc("cxl_host_bridge",
NR_CXL_HOST_BRIDGES + i);
if (!pdev)
goto err_bridge;
And similarly in cxl_rch_topo_init(), and for cxl_acpi in cxl_test_init()?
If platform_device_alloc() fails in these functions, could they return an
uninitialized rc or 0?
If they return 0, the test module is successfully loaded despite having freed
mock resources, leaving dangling pointers. When the module is subsequently
unloaded, cxl_test_exit() unregisters these platform devices again.
Could this cause a double-free and a kernel panic?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260629202720.3658117-1-dave.jiang@intel.com?part=3
next prev parent reply other threads:[~2026-06-29 20:38 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-29 20:27 [PATCH v6 0/6] cxl: Add CXL type2 accelerator support for cxl_test Dave Jiang
2026-06-29 20:27 ` [PATCH v6 1/6] cxl/test: Add test for module parameters Dave Jiang
2026-06-29 20:27 ` [PATCH v6 2/6] cxl/test: Add type2 support for mock CFMWS0 Dave Jiang
2026-06-29 20:27 ` [PATCH v6 3/6] cxl/test: Refactor platform device enumerations Dave Jiang
2026-06-29 20:38 ` sashiko-bot [this message]
2026-06-29 20:27 ` [PATCH v6 4/6] cxl/test: Add hierarchy enumeration support for type2 device Dave Jiang
2026-06-29 20:36 ` sashiko-bot
2026-06-29 20:43 ` Dave Jiang
2026-06-29 20:27 ` [PATCH v6 5/6] cxl/test: Fixup hdm init for auto region to support type2 Dave Jiang
2026-06-29 20:38 ` sashiko-bot
2026-06-29 20:27 ` [PATCH v6 6/6] cxl/test: Add cxl_test accelerator driver Dave Jiang
2026-06-29 20:37 ` sashiko-bot
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=20260629203856.B13621F000E9@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