All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Don't generate erroneous fixups from reference to path
@ 2022-07-31 12:11 David Gibson
       [not found] ` <20220731121100.253043-1-david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: David Gibson @ 2022-07-31 12:11 UTC (permalink / raw)
  To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA
  Cc: Vincent Pelletier, David Gibson

The dtb overlay format only permits (non local) fixups to reference labels,
not paths.  That's because the fixup target goes into the property name in
the overlay, and property names aren't permitted to include '/' characters.

Stop erroneously generating such fixups, because we didn't check for this
case.

Signed-off-by: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
---
 livetree.c                  | 6 ++++++
 tests/fixup-ref-to-path.dts | 6 ++++++
 tests/run_tests.sh          | 1 +
 3 files changed, 13 insertions(+)
 create mode 100644 tests/fixup-ref-to-path.dts

diff --git a/livetree.c b/livetree.c
index 169462d..f46a098 100644
--- a/livetree.c
+++ b/livetree.c
@@ -919,6 +919,12 @@ static void add_fixup_entry(struct dt_info *dti, struct node *fn,
 	/* m->ref can only be a REF_PHANDLE, but check anyway */
 	assert(m->type == REF_PHANDLE);
 
+	/* The format only permits fixups for references to label, not
+	 * references to path */
+	if (strchr(m->ref, '/'))
+		die("Can't generate fixup for reference to path &{%s}\n",
+		    m->ref);
+
 	/* there shouldn't be any ':' in the arguments */
 	if (strchr(node->fullpath, ':') || strchr(prop->name, ':'))
 		die("arguments should not contain ':'\n");
diff --git a/tests/fixup-ref-to-path.dts b/tests/fixup-ref-to-path.dts
new file mode 100644
index 0000000..f6dcba0
--- /dev/null
+++ b/tests/fixup-ref-to-path.dts
@@ -0,0 +1,6 @@
+/dts-v1/;
+/plugin/;
+
+/ {
+	prop = < &{/path/to/node} >;
+};
diff --git a/tests/run_tests.sh b/tests/run_tests.sh
index 0cabd13..244df8a 100755
--- a/tests/run_tests.sh
+++ b/tests/run_tests.sh
@@ -271,6 +271,7 @@ libfdt_overlay_tests () {
 	run_dtc_test -I dts -O dtb -o $tree.test.dtb "$SRCDIR/$tree.dts"
 	run_test overlay_bad_fixup overlay_base_no_symbols.test.dtb $tree.test.dtb
     done
+    run_sh_test "$SRCDIR/dtc-fatal.sh" -I dts -O dtb -o /dev/null fixup-ref-to-path.dts
 }
 
 # Tests to exercise dtc's overlay generation support
-- 
2.37.1


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

* Re: [PATCH] Don't generate erroneous fixups from reference to path
       [not found] ` <20220731121100.253043-1-david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
@ 2022-08-04  5:01   ` David Gibson
  0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2022-08-04  5:01 UTC (permalink / raw)
  To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA; +Cc: Vincent Pelletier

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

On Sun, Jul 31, 2022 at 10:11:00PM +1000, David Gibson wrote:
> The dtb overlay format only permits (non local) fixups to reference labels,
> not paths.  That's because the fixup target goes into the property name in
> the overlay, and property names aren't permitted to include '/' characters.
> 
> Stop erroneously generating such fixups, because we didn't check for this
> case.
> 
> Signed-off-by: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>

Well.. I guess I'll take no response as assent.  Applied to main
branch.

> ---
>  livetree.c                  | 6 ++++++
>  tests/fixup-ref-to-path.dts | 6 ++++++
>  tests/run_tests.sh          | 1 +
>  3 files changed, 13 insertions(+)
>  create mode 100644 tests/fixup-ref-to-path.dts
> 
> diff --git a/livetree.c b/livetree.c
> index 169462d..f46a098 100644
> --- a/livetree.c
> +++ b/livetree.c
> @@ -919,6 +919,12 @@ static void add_fixup_entry(struct dt_info *dti, struct node *fn,
>  	/* m->ref can only be a REF_PHANDLE, but check anyway */
>  	assert(m->type == REF_PHANDLE);
>  
> +	/* The format only permits fixups for references to label, not
> +	 * references to path */
> +	if (strchr(m->ref, '/'))
> +		die("Can't generate fixup for reference to path &{%s}\n",
> +		    m->ref);
> +
>  	/* there shouldn't be any ':' in the arguments */
>  	if (strchr(node->fullpath, ':') || strchr(prop->name, ':'))
>  		die("arguments should not contain ':'\n");
> diff --git a/tests/fixup-ref-to-path.dts b/tests/fixup-ref-to-path.dts
> new file mode 100644
> index 0000000..f6dcba0
> --- /dev/null
> +++ b/tests/fixup-ref-to-path.dts
> @@ -0,0 +1,6 @@
> +/dts-v1/;
> +/plugin/;
> +
> +/ {
> +	prop = < &{/path/to/node} >;
> +};
> diff --git a/tests/run_tests.sh b/tests/run_tests.sh
> index 0cabd13..244df8a 100755
> --- a/tests/run_tests.sh
> +++ b/tests/run_tests.sh
> @@ -271,6 +271,7 @@ libfdt_overlay_tests () {
>  	run_dtc_test -I dts -O dtb -o $tree.test.dtb "$SRCDIR/$tree.dts"
>  	run_test overlay_bad_fixup overlay_base_no_symbols.test.dtb $tree.test.dtb
>      done
> +    run_sh_test "$SRCDIR/dtc-fatal.sh" -I dts -O dtb -o /dev/null fixup-ref-to-path.dts
>  }
>  
>  # Tests to exercise dtc's overlay generation support

-- 
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:[~2022-08-04  5:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-31 12:11 [PATCH] Don't generate erroneous fixups from reference to path David Gibson
     [not found] ` <20220731121100.253043-1-david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
2022-08-04  5:01   ` David Gibson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.