Skip to contentSkip to conversation

checks: Check the overall length of "interrupt-map"

PATCH In review Rob Herring (Arm) 2 participants 2 messages May 31, 2024 – Jun 1, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 checks: Check the overall length of "interrupt-map"

It is possible the overall length of "interrupt-map" is shorter than expected. A likely scenario is if "#address-cells" in the interrupt parent is not accounted for and there is only a single map entry. With multiple entries, one of the other tests would likely fail.

---
 checks.c | 4 ++++
 1 file changed, 4 insertions(+)
checks.c +4 -0
index 28f86ccff56b..1950c18dd333 100644
@@ -1677,6 +1677,10 @@ static void check_interrupt_map(struct check *c,
 			parent_cellsize += propval_cell(cellprop);
 
 		cell += 1 + parent_cellsize;
+		if (cell > map_cells)
+			FAIL_PROP(c, dti, node, irq_map_prop,
+				"property size (%d) mismatch, expected %zu",
+				irq_map_prop->val.len, cell * sizeof(cell_t));
 	}
 }
 WARNING(interrupt_map, check_interrupt_map, NULL, &phandle_references, &addr_size_cells, &interrupt_provider);
Signature · 1 line
2.43.0
#1 lore raw
Quoted 6 lines · Rob Herring (Arm)

It is possible the overall length of "interrupt-map" is shorter than expected. A likely scenario is if "#address-cells" in the interrupt parent is not accounted for and there is only a single map entry. With multiple entries, one of the other tests would likely fail.

Applied, thanks. Of course, a test case for this would be a nice followup.

Quoted 19 lines
---
 checks.c | 4 ++++
 1 file changed, 4 insertions(+)
checks.c +4 -0
index 28f86ccff56b..1950c18dd333 100644
@@ -1677,6 +1677,10 @@ static void check_interrupt_map(struct check *c,
 			parent_cellsize += propval_cell(cellprop);
 
 		cell += 1 + parent_cellsize;
+		if (cell > map_cells)
+			FAIL_PROP(c, dti, node, irq_map_prop,
+				"property size (%d) mismatch, expected %zu",
+				irq_map_prop->val.len, cell * sizeof(cell_t));
 	}
 }
 WARNING(interrupt_map, check_interrupt_map, NULL, &phandle_references, &addr_size_cells, &interrupt_provider);
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson