From: sashiko-bot@kernel.org
To: "Marek Vasut" <marek.vasut+renesas@mailbox.org>
Cc: Frank.Li@kernel.org, imx@lists.linux.dev,
wsa+renesas@sang-engineering.com, linux-pci@vger.kernel.org
Subject: Re: [PATCH 1/2] PCI: dwc: Handle return value from endpoint .init callback
Date: Tue, 28 Jul 2026 01:40:28 +0000 [thread overview]
Message-ID: <20260728014029.116661F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260728012548.465139-2-marek.vasut+renesas@mailbox.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Double execution of `dw_pcie_edma_remove()` on the `dw_pcie_ep_init_registers()` error path leads to double-free of eDMA IRQs and DMA device unregistration list corruption.
--
--- Patch [1]: [PATCH 1/2] PCI: dwc: Handle return value from endpoint .init callback ---
commit cb2920cc5e4b5269e0e38169339b1b10e422e580
Author: Marek Vasut <marek.vasut+renesas@mailbox.org>
PCI: dwc: Handle return value from endpoint .init callback
Add return value handling for struct dw_pcie_ep_ops .init callback.
> diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c
> index 7d2794945704e..d78fb845582b2 100644
> --- a/drivers/pci/controller/dwc/pcie-designware-ep.c
> +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
[ ... ]
> @@ -1367,8 +1367,11 @@ int dw_pcie_ep_init_registers(struct dw_pcie_ep *ep)
> list_add_tail(&ep_func->list, &ep->func_list);
> }
>
> - if (ep->ops->init)
> - ep->ops->init(ep);
> + if (ep->ops->init) {
> + ret = ep->ops->init(ep);
> + if (ret)
> + goto err_remove_edma;
> + }
[Severity: High]
This is a pre-existing issue, but by handling the return value here, this
error path becomes more easily reachable. Can this lead to a double-free
of eDMA IRQs and list corruption?
If ep->ops->init() fails, the code jumps to err_remove_edma which calls
dw_pcie_edma_remove(pci) and returns the error code.
The caller typically catches this error and cleans up again:
drivers/pci/controller/dwc/pci-layerscape-ep.c:ls_pcie_ep_probe() {
...
ret = dw_pcie_ep_init_registers(&pci->ep);
if (ret) {
...
dw_pcie_ep_deinit(&pci->ep);
return ret;
}
}
dw_pcie_ep_deinit() then calls dw_pcie_ep_cleanup(), which unconditionally
executes dw_pcie_edma_remove(pci) a second time.
Since dw_edma_remove() does not clear its internal state (chip->dw = NULL)
after freeing resources, will this second invocation cause a double-free
or kernel oops during a device probe failure?
>
> dw_pcie_ep_disable_bars(ep);
>
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260728012548.465139-1-marek.vasut+renesas@mailbox.org?part=1
next prev parent reply other threads:[~2026-07-28 1:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-28 1:24 [PATCH 0/2] PCI: dwc: Handle return value from endpoint .init/.preinit callbacks Marek Vasut
2026-07-28 1:24 ` [PATCH 1/2] PCI: dwc: Handle return value from endpoint .init callback Marek Vasut
2026-07-28 1:40 ` sashiko-bot [this message]
2026-07-28 5:09 ` Siddharth Vadapalli
2026-07-28 1:24 ` [PATCH 2/2] PCI: dwc: Handle return value from endpoint .pre_init callback Marek Vasut
2026-07-28 1:37 ` sashiko-bot
2026-07-28 5:12 ` Siddharth Vadapalli
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=20260728014029.116661F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=imx@lists.linux.dev \
--cc=linux-pci@vger.kernel.org \
--cc=marek.vasut+renesas@mailbox.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=wsa+renesas@sang-engineering.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