mirror of
https://github.com/torvalds/linux.git
synced 2024-12-31 07:11:47 +00:00
PCI: mvebu: Check for valid ports
Some mvebu ports do not have to be initialized. So skip these uninitialized mvebu ports in every port iteration function to prevent access to unmapped memory or dereferencing NULL pointers. Uninitialized mvebu port has base address set to NULL. Link: https://lore.kernel.org/r/20211125124605.25915-2-pali@kernel.org Signed-off-by: Pali Rohár <pali@kernel.org> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
This commit is contained in:
parent
600b790309
commit
8cdabfdd5a
@ -606,6 +606,9 @@ static struct mvebu_pcie_port *mvebu_pcie_find_port(struct mvebu_pcie *pcie,
|
||||
for (i = 0; i < pcie->nports; i++) {
|
||||
struct mvebu_pcie_port *port = &pcie->ports[i];
|
||||
|
||||
if (!port->base)
|
||||
continue;
|
||||
|
||||
if (bus->number == 0 && port->devfn == devfn)
|
||||
return port;
|
||||
if (bus->number != 0 &&
|
||||
@ -781,6 +784,8 @@ static int mvebu_pcie_suspend(struct device *dev)
|
||||
pcie = dev_get_drvdata(dev);
|
||||
for (i = 0; i < pcie->nports; i++) {
|
||||
struct mvebu_pcie_port *port = pcie->ports + i;
|
||||
if (!port->base)
|
||||
continue;
|
||||
port->saved_pcie_stat = mvebu_readl(port, PCIE_STAT_OFF);
|
||||
}
|
||||
|
||||
@ -795,6 +800,8 @@ static int mvebu_pcie_resume(struct device *dev)
|
||||
pcie = dev_get_drvdata(dev);
|
||||
for (i = 0; i < pcie->nports; i++) {
|
||||
struct mvebu_pcie_port *port = pcie->ports + i;
|
||||
if (!port->base)
|
||||
continue;
|
||||
mvebu_writel(port, port->saved_pcie_stat, PCIE_STAT_OFF);
|
||||
mvebu_pcie_setup_hw(port);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user