PCI: rcar-host: Remove unused LIST_HEAD(res)
Subsystems (4)
PATCH v2 1/1 PCI: rcar-host: Remove unused LIST_HEAD(res)
From: Lad Prabhakar <[email protected]>
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;
---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(-)
drivers/pci/controller/pcie-rcar-host.c +0 -1
@@ -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 ;/* Try setting 5 GT/s link speed */
Signature · 1 line
2.54.0
Manivannan Sadhasivam
AppliedQuoted 8 lines · Prabhakar
Remove the unused
LIST_HEAD(res)declaration fromrcar_pcie_hw_enable().The macro instantiation defines an unused 'struct
list_headres' variable, which conflicts with a valid resource loop-local 'struct resource *res' declaration further down in the function, triggering a compiler variable shadowing warning:[...]
Applied, thanks!
[1/1] PCI: rcar-host: Remove unused LIST_HEAD(res)
commit: 6ba90ce2069ae923b0ec787aebdf2d786e5d2a58
Best regards,
Signature · 1 line
Manivannan Sadhasivam <[email protected]>
Quoted 30 lines · Prabhakar
From: Lad Prabhakar <[email protected]>
Remove the unused
LIST_HEAD(res)declaration fromrcar_pcie_hw_enable().The macro instantiation defines an unused 'struct
list_headres' 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 <[email protected]>Reviewed-by Geert Uytterhoeven <[email protected]>Reviewed-by Marek Vasut <[email protected]>---
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(-)drivers/pci/controller/pcie-rcar-host.c +0
-0
drivers/pci/controller/pcie-rcar-host.c static void rcar_pcie_hw_enable(struct rcar_pcie_host *host) · line 349
Quoted 5 lines
drivers/pci/controller/pcie-rcar-host.c +0
-1@@ -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()?
Quoted 39 lines · Bjorn Helgaas
Quoted 30 lines · Prabhakar
From: Lad Prabhakar <[email protected]>
Remove the unused
LIST_HEAD(res)declaration fromrcar_pcie_hw_enable().The macro instantiation defines an unused 'struct
list_headres' 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 <[email protected]>Reviewed-by Geert Uytterhoeven <[email protected]>Reviewed-by Marek Vasut <[email protected]>---
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(-)drivers/pci/controller/pcie-rcar-host.c +0
-0drivers/pci/controller/pcie-rcar-host.c static void rcar_pcie_hw_enable(struct rcar_pcie_host *host) · line 349
Quoted 5 lines
drivers/pci/controller/pcie-rcar-host.c +0
-1@@ -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:
Quoted 3 lines
[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?
I believe this is addressed in
[PATCH] PCI: rcar-host: Validate IO/MEM resource count in DT ranges property
Thank you.