From: Chen Pei <cp0613@linux.alibaba.com>
To: sashiko-bot@kernel.org
Cc: cp0613@linux.alibaba.com, linux-pci@vger.kernel.org,
sashiko-reviews@lists.linux.dev
Subject: Re: [PATCH] cxl/acpi: Defer probe when ACPI0016 PCI root bridge is not ready
Date: Tue, 26 May 2026 17:26:46 +0800 [thread overview]
Message-ID: <20260526092652.171319-1-cp0613@linux.alibaba.com> (raw)
In-Reply-To: <20260526031200.C19341F000E9@smtp.kernel.org>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=y, Size: 2420 bytes --]
On Tue, 26 May 2026 03:12:00 +0000, sashiko-bot@kernel.org wrote:
> > +
> > + /* Clear _DEP dependencies to allow consumers to enumerate */
> > + acpi_dev_clear_dependencies(device);
> > +
> > return 1;
> >
> > remove_dmar:
> > if (hotadd)
> > dmar_device_remove(handle);
> > end:
> > kfree(root);
>
> [Severity: High]
> This is a pre-existing issue, but does the dmar_device_add() error path
> leave a dangling pointer in device->driver_data?
>
> Earlier in acpi_pci_root_add(), the allocated root object is assigned to
> device->driver_data:
>
> root->device = device;
> root->segment = segment & 0xFFFF;
> device->driver_data = root;
>
> If dmar_device_add() fails during a hot-add, the code jumps to the end
> label and frees the root pointer via kfree().
>
> However, it doesn't explicitly reset device->driver_data to NULL, unlike
> the later pci_acpi_scan_root() error path. Since the ACPI core does not
> automatically clear driver_data on an attach failure, could subsequent calls
> to acpi_pci_find_root() by other subsystems fetch and dereference this freed
> pointer?
Good catch — you're right. On the dmar_device_add() failure path, the
code jumps to end: and frees root via kfree(), but
device->driver_data is left pointing at the freed memory. The later
pci_acpi_scan_root() failure path explicitly clears it to NULL, which
makes the omission on the dmar path look like an oversight rather than
intentional.
Since this is unrelated to the _DEP clearing change in this patch, I'd
prefer to keep it out of this patch and send a separate fix on top. Both
failure paths converge at end: and need the same cleanup, so I plan to
consolidate the NULL assignment there:
@@ -724,7 +724,6 @@ static int acpi_pci_root_add(struct acpi_device *device,
if (!root->bus) {
dev_err(&device->dev,
"Bus %04x:%02x not present in PCI namespace\n",
root->segment, (unsigned int)root->secondary.start);
- device->driver_data = NULL;
result = -ENODEV;
goto remove_dmar;
}
@@ -764,6 +763,7 @@ static int acpi_pci_root_add(struct acpi_device *device,
remove_dmar:
if (hotadd)
dmar_device_remove(handle);
end:
+ device->driver_data = NULL;
kfree(root);
return result;
}
This way every path reaching end: clears driver_data before freeing
root, and any future error path that does goto end; is automatically
correct. Does that split sound OK to you?
Thanks,
Pei
next prev parent reply other threads:[~2026-05-26 9:27 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-26 2:51 [PATCH 0/2] ACPI/PCI/CXL: Enforce _DEP ordering between ACPI0016 and ACPI0017 Chen Pei
2026-05-26 2:51 ` [PATCH 1/2] ACPI: PCI: Clear _DEP dependencies after PCI root bridge attach Chen Pei
2026-05-26 3:12 ` sashiko-bot
2026-05-26 9:26 ` Chen Pei [this message]
2026-05-26 2:51 ` [PATCH 2/2] ACPI: scan: Honor _DEP for ACPI0016 PCI/CXL host bridge Chen Pei
2026-05-27 11:38 ` Rafael J. Wysocki
2026-05-26 15:01 ` [PATCH 0/2] ACPI/PCI/CXL: Enforce _DEP ordering between ACPI0016 and ACPI0017 Dave Jiang
2026-05-27 1:14 ` Alison Schofield
2026-06-01 17:27 ` Rafael J. Wysocki
-- strict thread matches above, loose matches on Subject: below --
2026-05-14 2:32 [PATCH] cxl/acpi: Defer probe when ACPI0016 PCI root bridge is not ready Chen Pei
2026-05-14 7:31 ` Richard Cheng
2026-05-15 13:46 ` Chen Pei
2026-05-15 19:24 ` Dan Williams (nvidia)
2026-05-19 1:55 ` Chen Pei
2026-05-21 17:13 ` Dave Jiang
2026-05-14 17:10 ` Dave Jiang
2026-05-15 13:53 ` Chen Pei
2026-05-14 17:19 ` Alison Schofield
2026-05-15 13:56 ` Chen Pei
2026-05-15 15:38 ` Dave Jiang
2026-05-19 1:50 ` Chen Pei
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=20260526092652.171319-1-cp0613@linux.alibaba.com \
--to=cp0613@linux.alibaba.com \
--cc=linux-pci@vger.kernel.org \
--cc=sashiko-bot@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.