devicetree-compiler.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] checks: Check the overall length of "interrupt-map"
@ 2024-05-31 13:31 Rob Herring (Arm)
  2024-06-01  8:31 ` David Gibson
  0 siblings, 1 reply; 2+ messages in thread
From: Rob Herring (Arm) @ 2024-05-31 13:31 UTC (permalink / raw)
  To: devicetree-compiler

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.

Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
---
 checks.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/checks.c b/checks.c
index 28f86ccff56b..1950c18dd333 100644
--- a/checks.c
+++ b/checks.c
@@ -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);
-- 
2.43.0


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

* Re: [PATCH] checks: Check the overall length of "interrupt-map"
  2024-05-31 13:31 [PATCH] checks: Check the overall length of "interrupt-map" Rob Herring (Arm)
@ 2024-06-01  8:31 ` David Gibson
  0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2024-06-01  8:31 UTC (permalink / raw)
  To: Rob Herring (Arm); +Cc: devicetree-compiler

[-- Attachment #1: Type: text/plain, Size: 1341 bytes --]

On Fri, May 31, 2024 at 08:31:49AM -0500, Rob Herring (Arm) wrote:
> 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.
> 
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>

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

> ---
>  checks.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/checks.c b/checks.c
> index 28f86ccff56b..1950c18dd333 100644
> --- a/checks.c
> +++ b/checks.c
> @@ -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);

-- 
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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2024-06-01  8:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-31 13:31 [PATCH] checks: Check the overall length of "interrupt-map" Rob Herring (Arm)
2024-06-01  8:31 ` David Gibson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).