Re: [RFC PATCH 51/77] dtc: Avoid NULL fullpath for nodes in orphan trees
David Gibson <[email protected]> Thu, 15 Jan 2026 17:56:07 +1100
| Newsgroups | org.kernel.vger.devicetree-spec,org.kernel.vger.devicetree-compiler,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <aWiPhz92DBQImUw1@zatzit> |
On Mon, Jan 12, 2026 at 03:19:41PM +0100, Herve Codina wrote:
> Orphan nodes have been introduced recently.
>
> The process_checks() function uses fullpath in several places and
> crashes due NULL pointer dereferences if fullpath is NULL.
>
> In order to have process_checks() function running without crashes with
> orphan trees (i.e. trees based on orphan nodes), the fullpath of node
> available in those orphan trees must not be NULL.
>
> Fullpath values are built by dti_fill_fullpaths(). Update it to handle
> fullpath in trees based on orphan nodes.
>
> Use a simple "__orphan__/" prefix to avoid the NULL pointer and to be
> distinct from the root node ("/" prefix).
>
> It is worth noting that this "__orphan__/" prefix is a temporary prefix
> and it will be change later when support for reference by path involving
> nodes in orphan tree is added.
It might be simpler to eliminate the fullpath field entirely, and
instead have a function that calculates fullpaths at the point you
need them.
>
> Signed-off-by: Herve Codina <[email protected]>
> ---
> dtc.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/dtc.c b/dtc.c
> index 59f4d77..5cf8f31 100644
> --- a/dtc.c
> +++ b/dtc.c
> @@ -47,9 +47,14 @@ static void fill_fullpaths(struct node *tree, const char *prefix)
>
> static void dti_fill_fullpaths(struct dt_info *dti)
> {
> + struct node *orphan;
> +
> /* Fill fullpaths for the root node */
> if (dti->dt)
> fill_fullpaths(dti->dt, "");
> +
> + for_each_orphan(dti->orphanlist, orphan)
> + fill_fullpaths(orphan, "__orphan__/");
> }
>
> /* Usage related data. */
> --
> 2.52.0
>
>
--
David Gibson (he or they) | 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
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmloj4cACgkQzQJF27ox 2GdeEA//QngfyJtHSGb7EzSYkD/tdMl7RFk2CaOHxwGkLLZYL79i5AjbBYZM/L7F pCtdCmtyEhRRN0N58Jd3OTGYf+WGIC3DpzzpwJ3XbwUANVoL98SoATxJNtiyJNVh hvgy5j4OHuxXknFgY5kOXZ9GtPxec+PvXyp6frDpPJNIBxSsi4r1IWRInNatupIR qQa9DVDFCsD3P6UL/VK0EacF+hrq8YzK5qANmzjJE4l9gX8ADWR6AVMVfM75/nmn KotTaSBBEBcP1NSv292hYF/C21eyKZGIiwfeY6ypA/BNzBOqFbomtWwVn+brL2YP H4+0s/CwYJ8HKzYyBNrih6n9zyEev7GpP1pjQJGSgh6hWK52NeoL9uigSj+6vx9f 7eBQEdk/am3pdPKSEZ03SC+ZnqP6tmnpYIaloVbMxCHAYkJvrjiqtmjN5Mtmzls9 mXEqDGniE0voIeqDar8gXDSCSWzReZLGoHv5/PYJDUUCp9FKg35Ggilpja9w34Ea CBkEIVyrrWUPmA9dSoUWVFVCmF4WsM9FZVkYj6WEfvTvB5axXKKq/8Md2NeXpfpR 37w8BeBSPaAWh051vDZBpuugwv4F6pdq1lVoHeV6p0Wex4XaiI4c9u29roNpOQiD CcXRTUeAtRFqDyxm8V1w4ECBNGEp6h6Jzs6DyWb3YtjD5x0bQ34= =CdWX -----END PGP SIGNATURE-----