From: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>
To: devicetree-compiler@vger.kernel.org
Cc: Rob Herring <robh@kernel.org>,
Geert Uytterhoeven <geert@linux-m68k.org>,
"Saravana Kannan" <saravanak@google.com>,
devicetree@vger.kernel.org
Subject: [PATCH] libfdt: overlay: Fix phandle overwrite check for new subtrees
Date: Wed, 26 Jun 2024 09:55:52 +0200 [thread overview]
Message-ID: <20240626075551.2493048-2-u.kleine-koenig@baylibre.com> (raw)
If the overlay's target is only created in a previous fragment, it
doesn't exist in the unmodified base device tree. For the phandle
overwrite check this can be ignored because in this case the base tree
doesn't contain a phandle that could be overwritten.
Adapt the corresponding check to not error out if that happens but just
continue with the next fragment.
This is currently triggered by
arch/arm64/boot/dts/renesas/salvator-panel-aa104xd12.dtso in the kernel
repository which creates /panel in its first fragment and modifies it in
its second.
Reported-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/all/CAL_JsqL9MPycDjqQfPNAuGfC6EMrdzUivr+fuOS7YgU3biGd4A@mail.gmail.com/
Fixes: 1fad065080e6 ("libfdt: overlay: ensure that existing phandles are not overwritten")
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
---
libfdt/fdt_overlay.c | 8 +++++++-
tests/overlay_overlay_bypath.dts | 4 ++++
tests/overlay_overlay_no_fixups.dts | 8 ++++++++
3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/libfdt/fdt_overlay.c b/libfdt/fdt_overlay.c
index e19506fb56a5..28b667ffc490 100644
--- a/libfdt/fdt_overlay.c
+++ b/libfdt/fdt_overlay.c
@@ -729,7 +729,13 @@ static int overlay_prevent_phandle_overwrite(void *fdt, void *fdto)
return overlay;
target = fdt_overlay_target_offset(fdt, fdto, fragment, NULL);
- if (target < 0)
+ if (target == -FDT_ERR_NOTFOUND)
+ /*
+ * The subtree doesn't exist in the base, so nothing
+ * will be overwritten.
+ */
+ continue;
+ else if (target < 0)
return target;
ret = overlay_prevent_phandle_overwrite_node(fdt, target,
diff --git a/tests/overlay_overlay_bypath.dts b/tests/overlay_overlay_bypath.dts
index f23e7b6035e2..dfcb7cdb25a4 100644
--- a/tests/overlay_overlay_bypath.dts
+++ b/tests/overlay_overlay_bypath.dts
@@ -46,3 +46,7 @@
new-sub-test-property;
};
};
+
+&{/new-local-node} {
+ another-new-property;
+};
diff --git a/tests/overlay_overlay_no_fixups.dts b/tests/overlay_overlay_no_fixups.dts
index e8d0f96d889c..1dbdcdc2b40f 100644
--- a/tests/overlay_overlay_no_fixups.dts
+++ b/tests/overlay_overlay_no_fixups.dts
@@ -72,6 +72,14 @@
};
};
+ fragment@7 {
+ target-path = "/new-local-node";
+
+ __overlay__ {
+ another-new-property;
+ };
+ };
+
__local_fixups__ {
fragment@5 {
__overlay__ {
base-commit: ff4f17eb58650784ffb2e8a8fbefebce1038f80b
--
2.43.0
next reply other threads:[~2024-06-26 7:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-26 7:55 Uwe Kleine-König [this message]
2024-07-02 13:44 ` [PATCH] libfdt: overlay: Fix phandle overwrite check for new subtrees Uwe Kleine-König
2024-07-03 17:06 ` Rob Herring
2024-07-05 11:49 ` David Gibson
2024-07-05 20:53 ` Uwe Kleine-König
2024-07-05 23:46 ` David Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240626075551.2493048-2-u.kleine-koenig@baylibre.com \
--to=u.kleine-koenig@baylibre.com \
--cc=devicetree-compiler@vger.kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=geert@linux-m68k.org \
--cc=robh@kernel.org \
--cc=saravanak@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).