Skip to contentSkip to conversation

fdt: fix for add_subnode()

PATCH Leif Lindholm 3 participants 3 messages Dec 4, 2013 – Dec 5, 2013

lore
Share & tools
lore
#0 lore raw

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 <[email protected]>
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(+)
ChangeLog +4 -0
index ccd9e8e..1a96695 100644
@@ -1,3 +1,7 @@
+2013-12-04  Leif Lindholm  <[email protected]>
+
+	* grub-core/kern/fdt.c: Update struct size when adding node.
+
 2013-12-04  Vladimir Serbinenko  <[email protected]>
 
 	* configure.ac: Allow compilation with older GCC for ARM.
grub-core/lib/fdt.c +2 -0
index 9b77e1c..9c886fc 100644
@@ -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));
 }
Signature · 1 line
1.7.10.4
#1 lore raw

Hi,

Quoted 2 lines · Leif Lindholm

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

Looks ok to me.

--
Francesco