public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] pci: Add boundary check for hose->regions
@ 2019-03-15 15:32 Thierry Reding
  2019-03-15 15:32 ` [U-Boot] [PATCH 2/2] pci: Scale MAX_PCI_REGIONS based on CONFIG_NR_DRAM_BANKS Thierry Reding
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Thierry Reding @ 2019-03-15 15:32 UTC (permalink / raw)
  To: u-boot

From: Thierry Reding <treding@nvidia.com>

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>
---
 drivers/pci/pci-uclass.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
index 824fa1190747..cf1e7617ae35 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,
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-04-24 13:27 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-15 15:32 [U-Boot] [PATCH 1/2] pci: Add boundary check for hose->regions Thierry Reding
2019-03-15 15:32 ` [U-Boot] [PATCH 2/2] pci: Scale MAX_PCI_REGIONS based on CONFIG_NR_DRAM_BANKS Thierry Reding
2019-03-22  7:53   ` Simon Glass
2019-04-24 13:27   ` [U-Boot] [U-Boot, " Tom Rini
2019-03-22  7:53 ` [U-Boot] [PATCH 1/2] pci: Add boundary check for hose->regions Simon Glass
2019-04-16 16:30 ` Thierry Reding
2019-04-22 13:52   ` Tom Rini
2019-04-24 13:27 ` [U-Boot] [U-Boot, " Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox