All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Sean Edmond <seanedmond@microsoft.com>,
	Tom Rini <trini@konsulko.com>, Simon Glass <sjg@chromium.org>,
	Jerry Van Baren <vanbaren@cideas.com>
Subject: [PATCH 2/7] fdt: Check for a valid fdt in oftree_ensure()
Date: Sun, 12 Nov 2023 08:27:45 -0700	[thread overview]
Message-ID: <20231112152754.130399-3-sjg@chromium.org> (raw)
In-Reply-To: <20231112152754.130399-1-sjg@chromium.org>

Check the header before starting to use it, since this could provide
very confusing later, when ofnode calls start to fail.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/core/ofnode.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index c3d326831fc6..3956e1999c36 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -83,6 +83,11 @@ static oftree oftree_ensure(void *fdt)
 			if (check_tree_count())
 				return oftree_null();
 
+			if (fdt_check_header(fdt)) {
+				log_err("Invalid device tree blob header\n");
+				return oftree_null();
+			}
+
 			/* register the new tree */
 			i = oftree_count++;
 			oftree_list[i] = fdt;
-- 
2.42.0.869.gea05f2083d-goog


  parent reply	other threads:[~2023-11-12 15:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-12 15:27 [PATCH 0/7] fdt: Move towards using ofnode for devicetree fixups Simon Glass
2023-11-12 15:27 ` [PATCH 1/7] boot: Drop size parameter from image_setup_libfdt() Simon Glass
2023-11-12 18:22   ` Tom Rini
2023-12-13 20:39   ` Simon Glass
2023-11-12 15:27 ` Simon Glass [this message]
2023-11-12 15:27 ` [PATCH 3/7] fdt: Improve the comment for fdt_shrink_to_minimum() Simon Glass
2023-11-12 15:27 ` [PATCH 4/7] fdt: ppc: Drop extra size for ramdisk Simon Glass
2023-11-12 18:22   ` Tom Rini
2023-12-13 20:39   ` Simon Glass
2023-11-12 15:27 ` [PATCH 5/7] boot: Move adding initrd earlier in image_setup_libfdt() Simon Glass
2023-11-12 15:27 ` [PATCH 6/7] fdt: Drop the confusing casts in lmb_free() Simon Glass
2023-11-12 15:27 ` [PATCH 7/7] fdt: Move ft_verify_fdt() before the final fixups Simon Glass
2023-12-13 20:39 ` [PATCH 6/7] fdt: Drop the confusing casts in lmb_free() Simon Glass
2023-12-13 20:39 ` [PATCH 5/7] boot: Move adding initrd earlier in image_setup_libfdt() Simon Glass

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=20231112152754.130399-3-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=seanedmond@microsoft.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=vanbaren@cideas.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 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.