ARM: mvebu: don't dereference null bd pointer
Subsystems (3)
PATCH 1/1 ARM: mvebu: don't dereference null bd pointer
As mentioned in doc/README.arm-relocation gd->bd is not available in dram_init() so we shouldn't attempt to access it.
---
arch/arm/mach-mvebu/dram.c | 10 ---------- 1 file changed, 10 deletions(-)
arch/arm/mach-mvebu/dram.c +0 -10
@@ -281,16 +281,6 @@ int dram_init(void) size =MVEBU_SDRAM_SIZE_MAX ; } -for (; i <CONFIG_NR_DRAM_BANKS ; i++) { -/* If above loop terminated prematurely, we need to set -* remaining banks' start address & size as 0. Otherwise other -* u-boot functions and Linux kernel gets wrong values which -* could result in crash */ - gd->bd->bi_dram[i].start =0 ; - gd->bd->bi_dram[i].size =0 ; - } - -if (ecc_enabled ())dram_ecc_scrubbing ();
Signature · 1 line
2.23.0
PATCH 1/1 ARM: mvebu: don't dereference null bd pointer
Hi Chris,
Quoted 17 lines · Chris Packham
As mentioned in doc/README.arm-relocation
gd->bdis not available indram_init()so we shouldn't attempt to access it.Signed-off-by Chris Packham <[email protected]>---
arch/arm/mach-mvebu/dram.c | 10 ---------- 1 file changed, 10 deletions(-)arch/arm/mach-mvebu/dram.c +0
-0@@ -281,16 +281,6 @@ int dram_init(void) size =MVEBU_SDRAM_SIZE_MAX ; }
arch/arm/mach-mvebu/dram.c int dram_init(void) · line 293
Quoted 10 lines
arch/arm/mach-mvebu/dram.c +0
-10-for (; i <CONFIG_NR_DRAM_BANKS ; i++) { -/* If above loop terminated prematurely, we need to set -* remaining banks' start address & size as 0. Otherwise other -* u-boot functions and Linux kernel gets wrong values which -* could result in crash */ - gd->bd->bi_dram[i].start =0 ; - gd->bd->bi_dram[i].size =0 ; - } - -
How did you spot this issue? Did you see some crash / oops on one of your boards lately? I'm asking since I've never seen any issues with this code.
Thanks,
Stefan
PATCH 1/1 ARM: mvebu: don't dereference null bd pointer
Quoted 21 lines · Stefan Roese
Hi Chris,
Quoted 17 lines · Chris Packham
As mentioned in doc/README.arm-relocation
gd->bdis not available indram_init()so we shouldn't attempt to access it.Signed-off-by Chris Packham <[email protected]>---
arch/arm/mach-mvebu/dram.c | 10 ---------- 1 file changed, 10 deletions(-)arch/arm/mach-mvebu/dram.c +0
-0@@ -281,16 +281,6 @@ int dram_init(void) size =MVEBU_SDRAM_SIZE_MAX ; }
Quoted 15 lines
arch/arm/mach-mvebu/dram.c int dram_init(void) · line 293
Quoted 10 lines
arch/arm/mach-mvebu/dram.c +0
-10-for (; i <CONFIG_NR_DRAM_BANKS ; i++) { -/* If above loop terminated prematurely, we need to set -* remaining banks' start address & size as 0. Otherwise other -* u-boot functions and Linux kernel gets wrong values which -* could result in crash */ - gd->bd->bi_dram[i].start =0 ; - gd->bd->bi_dram[i].size =0 ; - } - -How did you spot this issue? Did you see some crash / oops on one of your boards lately? I'm asking since I've never seen any issues with this code.
Actually spotted this on another board.
Part of the $dayjob customisations include a diagnostic menu used for production testing. For mostly historical reasons we try and run the RAM test from the pre-relocation parts of u-boot. This lets us test all of RAM but as a consequence the bank start/size get overwritten with the test pattern so we hit a bug where the test would work the first time but then run off into the weeds the second time.
Aside from the wrongness I'm not aware of any problem this causes.
PATCH 1/1 ARM: mvebu: don't dereference null bd pointer
Quoted 40 lines · Chris Packham
Quoted 21 lines · Stefan Roese
Hi Chris,
Quoted 17 lines · Chris Packham
As mentioned in doc/README.arm-relocation
gd->bdis not available indram_init()so we shouldn't attempt to access it.Signed-off-by Chris Packham <[email protected]>---
arch/arm/mach-mvebu/dram.c | 10 ---------- 1 file changed, 10 deletions(-)arch/arm/mach-mvebu/dram.c +0
-0@@ -281,16 +281,6 @@ int dram_init(void) size =MVEBU_SDRAM_SIZE_MAX ; }Quoted 15 lines
arch/arm/mach-mvebu/dram.c int dram_init(void) · line 293
Quoted 10 lines
arch/arm/mach-mvebu/dram.c +0
-10-for (; i <CONFIG_NR_DRAM_BANKS ; i++) { -/* If above loop terminated prematurely, we need to set -* remaining banks' start address & size as 0. Otherwise other -* u-boot functions and Linux kernel gets wrong values which -* could result in crash */ - gd->bd->bi_dram[i].start =0 ; - gd->bd->bi_dram[i].size =0 ; - } - -How did you spot this issue? Did you see some crash / oops on one of your boards lately? I'm asking since I've never seen any issues with this code.
Actually spotted this on another board.
Quoted 8 lines
Part of the $dayjob customisations include a diagnostic menu used for production testing. For mostly historical reasons we try and run the RAM test from the pre-relocation parts of u-boot. This lets us test all of RAM but as a consequence the bank start/size get overwritten with the test pattern so we hit a bug where the test would work the first time but then run off into the weeds the second time.
Aside from the wrongness I'm not aware of any problem this causes.
Thanks for the explanation.
Thanks,
Stefan
PATCH 1/1 ARM: mvebu: don't dereference null bd pointer
In reply to Chris PackhamQuoted 4 lines · Chris Packham
As mentioned in doc/README.arm-relocation
gd->bdis not available indram_init()so we shouldn't attempt to access it.Signed-off-by Chris Packham <[email protected]>
Applied to u-boot-marvell/master.
Thanks,
Stefan