Patchwork [U-Boot,4/7] powerpc/mpc8xxx: check SPD length before using part number

login
register
mail settings
Submitter York Sun
Date May 26, 2011, 11:25 p.m.
Message ID <1306452353-11611-4-git-send-email-yorksun@freescale.com>
Download mbox | patch
Permalink /patch/97638/
State Accepted
Commit d2246549c7a71a3fca240e78bbcda6951195cfe3
Delegated to: Kumar Gala
Headers show

Comments

York Sun - May 26, 2011, 11:25 p.m.
From: york <yorksun@freescale.com>

Only use DDR DIMM part number if SPD has valid length, to prevent from
display garbage in case SPD doesn't cover these fields.

Signed-off-by: York Sun <yorksun@freescale.com>
---
 arch/powerpc/cpu/mpc8xxx/ddr/ddr3_dimm_params.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
Kumar Gala - June 3, 2011, 7:42 a.m.
On May 26, 2011, at 6:25 PM, York Sun wrote:

> From: york <yorksun@freescale.com>
> 
> Only use DDR DIMM part number if SPD has valid length, to prevent from
> display garbage in case SPD doesn't cover these fields.
> 
> Signed-off-by: York Sun <yorksun@freescale.com>
> ---
> arch/powerpc/cpu/mpc8xxx/ddr/ddr3_dimm_params.c |    3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)

applied to 85xx next

- k

Patch

diff --git a/arch/powerpc/cpu/mpc8xxx/ddr/ddr3_dimm_params.c b/arch/powerpc/cpu/mpc8xxx/ddr/ddr3_dimm_params.c
index 756b15f..838cebe 100644
--- a/arch/powerpc/cpu/mpc8xxx/ddr/ddr3_dimm_params.c
+++ b/arch/powerpc/cpu/mpc8xxx/ddr/ddr3_dimm_params.c
@@ -114,7 +114,8 @@  ddr_compute_dimm_parameters(const ddr3_spd_eeprom_t *spd,
 	 * and copying the part name in ASCII from the SPD onto it
 	 */
 	memset(pdimm->mpart, 0, sizeof(pdimm->mpart));
-	memcpy(pdimm->mpart, spd->mpart, sizeof(pdimm->mpart) - 1);
+	if ((spd->info_size_crc & 0xF) > 1)
+		memcpy(pdimm->mpart, spd->mpart, sizeof(pdimm->mpart) - 1);
 
 	/* DIMM organization parameters */
 	pdimm->n_ranks = ((spd->organization >> 3) & 0x7) + 1;