sandbox: Replace set_working_fdt_addr with pointer version

Message ID 20180926091950.51513-1-agraf@suse.de
State New
Headers show
Series
  • sandbox: Replace set_working_fdt_addr with pointer version
Related show

Commit Message

Alexander Graf Sept. 26, 2018, 9:19 a.m.
When running sandbox with the new pointer sanitization we just recently
introduced, we're running into a case with FIT images where we end up
interpreting pointers as addresses.

Since most callers of the set_working_fdt_addr() function are already at
the pointer stage, let's just rename it to set_working_fdt() and pass in
the pointer directly.

This fixes sandbox fit tests for me.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 cmd/fdt.c             | 10 +++++-----
 common/bootm.c        |  2 +-
 common/image-fdt.c    |  2 +-
 include/fdt_support.h |  2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

Patch

diff --git a/cmd/fdt.c b/cmd/fdt.c
index 28de467f96..1976e7e6b9 100644
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -36,12 +36,12 @@  static int is_printable_string(const void *data, int len);
  */
 struct fdt_header *working_fdt;
 
-void set_working_fdt_addr(ulong addr)
+void set_working_fdt(char *fdt)
 {
-	void *buf;
+	uintptr_t addr;
 
-	buf = map_sysmem(addr, 0);
-	working_fdt = buf;
+	addr = map_to_sysmem(fdt);
+	working_fdt = fdt;
 	env_set_hex("fdtaddr", addr);
 }
 
@@ -121,7 +121,7 @@  static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		if (control)
 			gd->fdt_blob = blob;
 		else
-			set_working_fdt_addr(addr);
+			set_working_fdt(map_sysmem(addr, 0));
 
 		if (argc >= 2) {
 			int  len;
diff --git a/common/bootm.c b/common/bootm.c
index e517d9f118..5d3a60927d 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -262,7 +262,7 @@  int bootm_find_images(int flag, int argc, char * const argv[])
 		puts("Could not find a valid device tree\n");
 		return 1;
 	}
-	set_working_fdt_addr((ulong)images.ft_addr);
+	set_working_fdt(images.ft_addr);
 #endif
 
 #if IMAGE_ENABLE_FIT
diff --git a/common/image-fdt.c b/common/image-fdt.c
index 9b41f16248..f685d66fe9 100644
--- a/common/image-fdt.c
+++ b/common/image-fdt.c
@@ -193,7 +193,7 @@  int boot_relocate_fdt(struct lmb *lmb, char **of_flat_tree, ulong *of_size)
 	*of_flat_tree = of_start;
 	*of_size = of_len;
 
-	set_working_fdt_addr((ulong)*of_flat_tree);
+	set_working_fdt(*of_flat_tree);
 	return 0;
 
 error:
diff --git a/include/fdt_support.h b/include/fdt_support.h
index 27fe564f0b..5658296498 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -191,7 +191,7 @@  void ft_pci_setup(void *blob, bd_t *bd);
  */
 int ft_system_setup(void *blob, bd_t *bd);
 
-void set_working_fdt_addr(ulong addr);
+void set_working_fdt(char *fdt);
 
 /**
  * shrink down the given blob to minimum size + some extrasize if required