diff options
author | Thierry Reding <treding@nvidia.com> | 2019-03-15 16:32:32 +0100 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2019-04-23 17:57:23 -0400 |
commit | d94d9aa675b2d8a50b8b66b07f3210d291f7eaff (patch) | |
tree | b23369b36dbb5744eb1baec233243b49e42e12c0 /drivers/pci/pci-uclass.c | |
parent | 248b873541d0d62f45b3a08bffeb0523c2746f4c (diff) | |
download | u-boot-d94d9aa675b2d8a50b8b66b07f3210d291f7eaff.tar.gz u-boot-d94d9aa675b2d8a50b8b66b07f3210d291f7eaff.tar.xz u-boot-d94d9aa675b2d8a50b8b66b07f3210d291f7eaff.zip |
pci: Add boundary check for hose->regions
Make sure that we don't overflow the hose->regions array, otherwise we
would end up overwriting the hose->region_count field and cause mayhem
to ensue. Also print an error message when we'd be overflowing because
it indicates that there aren't enough regions available and the number
needs to be increased.
Signed-off-by: Thierry Reding <treding@nvidia.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/pci/pci-uclass.c')
-rw-r--r-- | drivers/pci/pci-uclass.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c index 824fa11907..cf1e7617ae 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -918,6 +918,11 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node, return; for (i = 0; i < CONFIG_NR_DRAM_BANKS; ++i) { + if (hose->region_count == MAX_PCI_REGIONS) { + pr_err("maximum number of regions parsed, aborting\n"); + break; + } + if (bd->bi_dram[i].size) { pci_set_region(hose->regions + hose->region_count++, bd->bi_dram[i].start, |