The current fdt support fails to update the size of the dt_struct after
adding a new node. Attached is the suggested fix.

/
    Leif
>From d424d2fe0581c1f036aae9a8b0371d65d007ef61 Mon Sep 17 00:00:00 2001
From: Leif Lindholm <leif.lindh...@linaro.org>
Date: Wed, 4 Dec 2013 12:59:21 +0000
Subject: [PATCH] grub-core/lib/fdt.c: correctly update size_dt_struct in
 add_subnode()

---
 ChangeLog           |    4 ++++
 grub-core/lib/fdt.c |    2 ++
 2 files changed, 6 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index ccd9e8e..1a96695 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2013-12-04  Leif Lindholm  <leif.lindh...@linaro.org>
+
+	* grub-core/kern/fdt.c: Update struct size when adding node.
+
 2013-12-04  Vladimir Serbinenko  <phco...@gmail.com>
 
 	* configure.ac: Allow compilation with older GCC for ARM.
diff --git a/grub-core/lib/fdt.c b/grub-core/lib/fdt.c
index 9b77e1c..9c886fc 100644
--- a/grub-core/lib/fdt.c
+++ b/grub-core/lib/fdt.c
@@ -132,6 +132,7 @@ static int add_subnode (void *fdt, int parentoffset, const char *name)
                                    + parentoffset);
   grub_uint32_t *end = (void *) struct_end (fdt);
   unsigned int entry_size = node_entry_size (name);
+  unsigned int struct_size = grub_fdt_get_size_dt_struct(fdt);
   char *node_name;
 
   SKIP_NODE_NAME(node_name, token, end);
@@ -167,6 +168,7 @@ insert:
   token[entry_size / sizeof(*token) - 2] = 0;	/* padding bytes */
   grub_strcpy((char *) (token + 1), name);
   token[entry_size / sizeof(*token) - 1] = grub_cpu_to_be32(FDT_END_NODE);
+  grub_fdt_set_size_dt_struct (fdt, struct_size + entry_size);
   return ((grub_addr_t) token - (grub_addr_t) fdt
           - grub_fdt_get_off_dt_struct(fdt));
 }
-- 
1.7.10.4

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to