Skip to contentSkip to conversation

arm: fix bd pointer dereference prior initialization

PATCH New Igor Grinberg 3 participants 6 messages Jul 28, 2011 – Aug 17, 2011 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: fix bd pointer dereference prior initialization

gd->bd pointer has been used prior been initialized. Move the relevant code after the initialization.

---
 arch/arm/lib/board.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
arch/arm/lib/board.c +4 -4
index bcbf697..52e90db 100644
@@ -281,10 +281,6 @@ void board_init_f (ulong bootflag)
 
 	gd->mon_len = _bss_end_ofs;
 
-#ifdef CONFIG_MACH_TYPE
-	gd->bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */
-#endif
-
 	for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
 		if ((*init_fnc_ptr)() != 0) {
 			hang ();
@@ -409,6 +405,10 @@ void board_init_f (ulong bootflag)
 	post_run (NULL, POST_ROM | post_bootmode_get(0));
 #endif
 
+#ifdef CONFIG_MACH_TYPE
+	gd->bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */
+#endif
+
 	gd->bd->bi_baudrate = gd->baudrate;
 	/* Ram ist board specific, so move it to board code ... */
 	dram_init_banksize();
Signature · 1 line
1.7.3.4
#1 lore raw

PATCH 1/1 arm: fix bd pointer dereference prior initialization

Quoted 4 lines · Igor Grinberg

gd->bd pointer has been used prior been initialized. Move the relevant code after the initialization.

Quoted 34 lines

---
?arch/arm/lib/board.c | ? ?8 ++++----
?1 files changed, 4 insertions(+), 4 deletions(-)

arch/arm/lib/board.c +0 -4
index bcbf697..52e90db 100644
@@ -281,10 +281,6 @@ void board_init_f (ulong bootflag)
 
 ? ? ? ?gd->mon_len = _bss_end_ofs;
 
-#ifdef CONFIG_MACH_TYPE
- ? ? ? gd->bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */
-#endif
-
 ? ? ? ?for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
 ? ? ? ? ? ? ? ?if ((*init_fnc_ptr)() != 0) {
 ? ? ? ? ? ? ? ? ? ? ? ?hang ();
@@ -409,6 +405,10 @@ void board_init_f (ulong bootflag)
 ? ? ? ?post_run (NULL, POST_ROM | post_bootmode_get(0));

?#endif

arch/arm/lib/board.c +4 -0
+#ifdef CONFIG_MACH_TYPE
+ ? ? ? gd->bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */
+#endif
+

? ? ? ?gd->bd->bi_baudrate = gd->baudrate;
? ? ? ?/* Ram ist board specific, so move it to board code ... */ ? ? ? ?dram_init_banksize();
--
1.7.3.4

Signature · 2 lines
with warm regards,
Chander Kashyap
#2 lore raw

PATCH 1/1 arm: fix bd pointer dereference prior initialization

In reply to Igor Grinberg

Hi Igor,

Quoted 24 lines · Igor Grinberg

gd->bd pointer has been used prior been initialized. Move the relevant code after the initialization.

---
  arch/arm/lib/board.c |    8 ++++----
  1 files changed, 4 insertions(+), 4 deletions(-)
arch/arm/lib/board.c +0 -4
index bcbf697..52e90db 100644
@@ -281,10 +281,6 @@ void board_init_f (ulong bootflag)
 
  	gd->mon_len = _bss_end_ofs;
 
-#ifdef CONFIG_MACH_TYPE
-	gd->bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */
-#endif
-
  	for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
  		if ((*init_fnc_ptr)() != 0) {
  			hang ();

arch/arm/lib/board.c void board_init_f (ulong bootflag) · line 414

Quoted 10 lines
arch/arm/lib/board.c +4 -0
@@ -409,6 +405,10 @@ void board_init_f (ulong bootflag)
  	post_run (NULL, POST_ROM | post_bootmode_get(0));
  #endif
 
+#ifdef CONFIG_MACH_TYPE
+	gd->bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */
+#endif
+
  	gd->bd->bi_baudrate = gd->baudrate;
  	/* Ram ist board specific, so move it to board code ... */
  	dram_init_banksize();

As a bugfix, I'd like to pull this patch in now. However, it does not apply cleanly to current u-boot-arm/master, and besides, I'd rather have the bi_arch_number initialized as soon as bd is set up, i.e. just after the assignment to gd->bd.

Amicalement,

Signature · 1 line
Albert.
#3 lore raw

PATCH 1/1 arm: fix bd pointer dereference prior initialization

Hi Albert,

Sorry for the poor responsiveness - I was out of office for about 2 weeks.

Quoted 30 lines · Albert ARIBAUD

Hi Igor,

Quoted 27 lines · Igor Grinberg

gd->bd pointer has been used prior been initialized. Move the relevant code after the initialization.

---
  arch/arm/lib/board.c |    8 ++++----
  1 files changed, 4 insertions(+), 4 deletions(-)
arch/arm/lib/board.c +0 -4
index bcbf697..52e90db 100644
@@ -281,10 +281,6 @@ void board_init_f (ulong bootflag)
 
      gd->mon_len = _bss_end_ofs;
 
-#ifdef CONFIG_MACH_TYPE
-    gd->bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */
-#endif
-
      for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
          if ((*init_fnc_ptr)() != 0) {
              hang ();
@@ -409,6 +405,10 @@ void board_init_f (ulong bootflag)
      post_run (NULL, POST_ROM | post_bootmode_get(0));
  #endif
 
Quoted 9 lines

arch/arm/lib/board.c void board_init_f (ulong bootflag) · line 414

Quoted 7 lines
arch/arm/lib/board.c +4 -0
+#ifdef CONFIG_MACH_TYPE
+    gd->bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */
+#endif
+
      gd->bd->bi_baudrate = gd->baudrate;
      /* Ram ist board specific, so move it to board code ... */
      dram_init_banksize();

As a bugfix, I'd like to pull this patch in now. However, it does not apply cleanly to current u-boot-arm/master, and besides, I'd rather have the bi_arch_number initialized as soon as bd is set up, i.e. just after the assignment to gd->bd.

Well, it applied cleanly for me...
Nevertheless, I'm sending a v2 rebased on top of the most recent u-boot-arm/master with your requested change.

Signature · 2 lines
Regards,
Igor.
#4 lore raw

PATCH v2 1/1 arm: fix bd pointer dereference prior initialization

In reply to Albert ARIBAUD

gd->bd pointer has been used prior been initialized. Move the relevant code after the initialization.

---
v2: move it closer to the bd pointer set up as for Albert's suggestion.

 arch/arm/lib/board.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
arch/arm/lib/board.c +5 -4
index 646cf45..c899839 100644
@@ -275,10 +275,6 @@ void board_init_f(ulong bootflag)
 
 	gd->mon_len = _bss_end_ofs;
 
-#ifdef CONFIG_MACH_TYPE
-	gd->bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */
-#endif
-
 	for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
 		if ((*init_fnc_ptr)() != 0) {
 			hang ();
@@ -376,6 +372,11 @@ void board_init_f(ulong bootflag)
 	gd->bd = bd;
 	debug("Reserving %zu Bytes for Board Info at: %08lx\n",
 			sizeof (bd_t), addr_sp);
+
+#ifdef CONFIG_MACH_TYPE
+	gd->bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */
+#endif
+
 	addr_sp -= sizeof (gd_t);
 	id = (gd_t *) addr_sp;
 	debug("Reserving %zu Bytes for Global Data at: %08lx\n",
Signature · 1 line
1.7.3.4
#5 lore raw

PATCH v2 1/1 arm: fix bd pointer dereference prior initialization

Hi Igor,

Le 17/08/2011 11:48, Igor Grinberg a ?crit :

Quoted 27 lines

gd->bd pointer has been used prior been initialized. Move the relevant code after the initialization.

---
v2: move it closer to the bd pointer set up as for Albert's suggestion.

  arch/arm/lib/board.c |    9 +++++----
  1 files changed, 5 insertions(+), 4 deletions(-)
arch/arm/lib/board.c +0 -4
index 646cf45..c899839 100644
@@ -275,10 +275,6 @@ void board_init_f(ulong bootflag)
 
  	gd->mon_len = _bss_end_ofs;
 
-#ifdef CONFIG_MACH_TYPE
-	gd->bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */
-#endif
-
  	for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
  		if ((*init_fnc_ptr)() != 0) {
  			hang ();
@@ -376,6 +372,11 @@ void board_init_f(ulong bootflag)
  	gd->bd = bd;

arch/arm/lib/board.c void board_init_f(ulong bootflag) · line 382

Quoted 10 lines
arch/arm/lib/board.c +5 -0
  	debug("Reserving %zu Bytes for Board Info at: %08lx\n",
  			sizeof (bd_t), addr_sp);
+
+#ifdef CONFIG_MACH_TYPE
+	gd->bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */
+#endif
+
  	addr_sp -= sizeof (gd_t);
  	id = (gd_t *) addr_sp;
  	debug("Reserving %zu Bytes for Global Data at: %08lx\n",

Applied to u-boot-arm/master, thanks!

Amicalement,

Signature · 1 line
Albert.