[PATCH] dm: core: Don't allow ofnode_to_fdt() to return NULL

Romain Gantois romain.gantois at bootlin.com
Tue Feb 17 10:16:37 CET 2026


Hi Tom,

On Monday, 16 February 2026 18:50:20 CET Tom Rini wrote:
> On Tue, Feb 10, 2026 at 05:29:01PM +0100, Romain Gantois wrote:
> > The ofnode_to_fdt() function may return a NULL pointer in multiple cases.
> > Or, this function's return value is often passed directly to functions
> > such
> > as fdt_getprop() which end up dereferencing it, thus causing a NULL
> > pointer
> > exception.
> > 
> > Don't allow ofnode_to_fdt() to return NULL, to avoid a NULL pointer
> > dereference.
> > 
> > Signed-off-by: Romain Gantois <romain.gantois at bootlin.com>
> 
> This leads to failures to build such as:
> +(neu6a-io-rk3588) drivers/core/ofnode.c: In function 'ofnode_to_fdt':
> +(neu6a-io-rk3588) drivers/core/ofnode.c:176:21: error: assignment discards
> 'const' qualifie  from pointer target type [-Werror=discarded-qualifiers]
> +(neu6a-io-rk3588)   176 |                 fdt = gd->fdt_blob;
> +(neu6a-io-rk3588)       |                     ^
> +(neu6a-io-rk3588) cc1: all warnings being treated as errors

Indeed, looks like the dropped (void *) cast is responsible for that.

Thanks,

-- 
Romain Gantois, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20260217/a802001c/attachment.sig>


More information about the U-Boot mailing list