Re: [PATCH v2] PCI: rcar-host: Remove unused LIST_HEAD(res)

From: Bjorn Helgaas

Date: Fri Oct 02 2026 - 19:34:47 EST


On Thu, May 21, 2026 at 10:12:56AM +0100, Prabhakar wrote:
> From: Lad Prabhakar <prabhakar.mahadev-lad.rj@xxxxxxxxxxxxxx>
>
> Remove the unused LIST_HEAD(res) declaration from rcar_pcie_hw_enable().
>
> The macro instantiation defines an unused 'struct list_head res' variable,
> which conflicts with a valid resource loop-local 'struct resource *res'
> declaration further down in the function, triggering a compiler variable
> shadowing warning:
>
> drivers/pci/controller/pcie-rcar-host.c:357:34: warning: declaration of 'res' shadows a previous local [-Wshadow]
> 357 | struct resource *res = win->res;
>
> Fixes: ce351636c67f75a9 ("PCI: rcar: Add suspend/resume")
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@xxxxxxxxxxxxxx>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>
> Reviewed-by: Marek Vasut <marek.vasut+renesas@xxxxxxxxxxx>
> ---
> v1->v2:
> - Updated the commit message to include the warning.
> - Added the Fixes tag.
> - Added Reviewed-by tags for Geert and Marek.
> ---
> drivers/pci/controller/pcie-rcar-host.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/drivers/pci/controller/pcie-rcar-host.c b/drivers/pci/controller/pcie-rcar-host.c
> index 213028052aa5..cd9171eebc28 100644
> --- a/drivers/pci/controller/pcie-rcar-host.c
> +++ b/drivers/pci/controller/pcie-rcar-host.c
> @@ -346,7 +346,6 @@ static void rcar_pcie_hw_enable(struct rcar_pcie_host *host)
> struct rcar_pcie *pcie = &host->pcie;
> struct pci_host_bridge *bridge = pci_host_bridge_from_priv(host);
> struct resource_entry *win;
> - LIST_HEAD(res);
> int i = 0;

Internal Sashiko feedback while backporting this patch:

[Severity: High]
This is a pre-existing issue, but does this function lack bounds checking
for the outbound window index 'i' when configuring PCI resources?

Looking at the loop just below this hunk in rcar_pcie_hw_enable():

resource_list_for_each_entry(win, &bridge->windows) {
...
switch (resource_type(res)) {
case IORESOURCE_IO:
case IORESOURCE_MEM:
rcar_pcie_set_outbound(pcie, i, win);
i++;
break;
}
}

If the device tree populates bridge->windows with more ranges than the
supported outbound window limit (RCAR_PCI_MAX_RESOURCES, which is 4), it
appears 'i' could exceed the limit. Could this result in an out-of-bounds
hardware register write during the calculation of the register offset in
rcar_pcie_set_outbound()?