]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
board: rzg2l: Check the DTB pointer passed by the TF-A.
authorMathieu Othacehe <othacehe@gnu.org>
Mon, 22 Sep 2025 16:29:00 +0000 (18:29 +0200)
committerMarek Vasut <marek.vasut+renesas@mailbox.org>
Thu, 25 Sep 2025 21:18:34 +0000 (23:18 +0200)
On the RZG2L platform, the advised
TF-A (https://github.com/renesas-rz/rzg_trusted-firmware-a/tree/v2.5/rzg2l)
does not pass any DTB blob to U-Boot.

On the other hand, the RZG2L part of U-Boot expects a DTB to be passed.  It
means that if one flashes the latest TF-A as well as the mainline U-Boot,
it will crash trying to dereference the NULL DTB pointer before outputing
anything.

Check if the DTB pointer is NULL before trying to use it.

Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
Reviewed-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
arch/arm/mach-renesas/cpu_info-rzg2l.c
board/renesas/rzg2l/rzg2l.c

index ab95ce76388ed16f251d9297562fc2f8fed3dc72..a9cb9f72dd32fd58fa234f20d4c079ab4b9d71ec 100644 (file)
@@ -30,7 +30,7 @@ static const struct tfa_info *get_tfa_info(void)
 {
        void *atf_fdt_blob = (void *)(rcar_atf_boot_args[1]);
 
-       if (fdt_magic(atf_fdt_blob) == FDT_MAGIC) {
+       if (atf_fdt_blob && fdt_magic(atf_fdt_blob) == FDT_MAGIC) {
                unsigned int i;
                for (i = 0; i < ARRAY_SIZE(tfa_info); i++) {
                        if (!fdt_node_check_compatible(atf_fdt_blob, 0,
index 509c5dbb156b7e6123a94358bc5bf5558444a9bf..3c8f8d04cbd54f3822977f7b38036aa2a973b557 100644 (file)
@@ -22,7 +22,7 @@ int board_fit_config_name_match(const char *name)
 {
        void *atf_fdt_blob = (void *)(rcar_atf_boot_args[1]);
 
-       if (fdt_magic(atf_fdt_blob) != FDT_MAGIC)
+       if (!atf_fdt_blob || fdt_magic(atf_fdt_blob) != FDT_MAGIC)
                return -1;
 
        if (is_rzg2l_board("renesas,r9a07g044l2"))
@@ -36,7 +36,7 @@ static void apply_atf_overlay(void *fdt_blob)
 {
        void *atf_fdt_blob = (void *)(rcar_atf_boot_args[1]);
 
-       if (fdt_magic(atf_fdt_blob) == FDT_MAGIC)
+       if (atf_fdt_blob && fdt_magic(atf_fdt_blob) == FDT_MAGIC)
                fdt_overlay_apply_node(fdt_blob, 0, atf_fdt_blob, 0);
 }