diff options
author | Pali Rohár <pali@kernel.org> | 2021-10-07 15:50:58 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-10-15 02:45:07 +0300 |
commit | 63ae80dd98d4c0d1123317043cdf2596e724e43a (patch) | |
tree | 34fefa8b5b79b9122847cbc9b659d893849ee23e /drivers | |
parent | b9caab8b47ae6ad6a317a9ed05e90475248739d7 (diff) | |
download | u-boot-63ae80dd98d4c0d1123317043cdf2596e724e43a.tar.xz |
pci: Skip configuring invalid P2P bridge devices
Function dm_pci_hose_probe_bus() expects that bus is valid PCI device with
Bridge header type (0x01). So add check before touching PCI config space to
prevent misconfiguring some non-standard device.
Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/pci/pci-uclass.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c index 044babee16..5da3515f5f 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -627,6 +627,7 @@ int pci_generic_mmap_read_config( int dm_pci_hose_probe_bus(struct udevice *bus) { + u8 header_type; int sub_bus; int ret; int ea_pos; @@ -634,6 +635,14 @@ int dm_pci_hose_probe_bus(struct udevice *bus) debug("%s\n", __func__); + dm_pci_read_config8(bus, PCI_HEADER_TYPE, &header_type); + header_type &= 0x7f; + if (header_type != PCI_HEADER_TYPE_BRIDGE) { + debug("%s: Skipping PCI device %d with Non-Bridge Header Type 0x%x\n", + __func__, PCI_DEV(dm_pci_get_bdf(bus)), header_type); + return log_msg_ret("probe", -EINVAL); + } + ea_pos = dm_pci_find_capability(bus, PCI_CAP_ID_EA); if (ea_pos) { dm_pci_read_config8(bus, ea_pos + sizeof(u32) + sizeof(u8), |