Bug fix / safty measure for cfi_flash.c
PATCH 1/1 Bug fix / safty measure for cfi_flash.c
Without this additional check a flash that was defined in the config file with different size then the one reported by the flash chip itself. will cause array overrun and crash.
the additional CONFIG_FORCE_FLASH_BANK_SIZE allows to set the size ignoring the chip actual size
diff -x .svn -Nuar u-boot.git-5ffa76a032279bc6d3230b703eda32d13305ba13/drivers/cfi_flash.c u-boot.exsw6000/drivers/cfi_flash.c
--- u-boot.git-5ffa76a032279bc6d3230b703eda32d13305ba13/drivers/cfi_flash.c
2007-06-18 22:38:46.000000000 +0300
+++ u-boot.exsw6000/drivers/cfi_flash.c 2007-06-20 19:05:01.000000000 +0300 @@ -1281,7 +1281,7 @@erase_region_count = (tmp & 0xffff) + 1;
debug ("erase_region_count = %d erase_region_size = %d\n", erase_region_count, erase_region_size);
- for (j = 0; j < erase_region_count; j++) {
+ for (j = 0; j < erase_region_count && sect_cnt < CFG_MAX_FLASH_SECT; j++) { info->start[sect_cnt] = sector;
sector += (erase_region_size * size_ratio);
@@ -1323,6 +1323,9 @@
}
flash_write_cmd (info, 0, 0, info->cmd_reset);
+#if defined(CONFIG_FORCE_FLASH_BANK_SIZE)
+ info->size = CONFIG_FORCE_FLASH_BANK_SIZE;
+#endif
return (info->size);
}
PATCH 1/1 Bug fix / safty measure for cfi_flash.c
Hi Eran,
Quoted 16 lines · eran liberty
Without this additional check a flash that was defined in the config file with different size then the one reported by the flash chip itself. will cause array overrun and crash.
the additional
CONFIG_FORCE_FLASH_BANK_SIZEallows to set the size ignoring the chip actual sizeSigned-off-by Eran Libertydiff -x .svn -Nuar
u-boot.git-5ffa76a032279bc6d3230b703eda32d13305ba13/drivers/cfi_flash.cu-boot.exsw6000/drivers/cfi_flash.c
---u-boot.git-5ffa76a032279bc6d3230b703eda32d13305ba13/drivers/cfi_flash.c2007-06-18 22:38:46.000000000 +0300+++
u-boot.exsw6000/drivers/cfi_flash.c2007-06-20 19:05:01.000000000 +0300
Review line 1281
Quoted 1 line
(quoted diff) +0
-0@@ -1281,7 +1281,7 @@ erase_region_count = (tmp & 0xffff) + 1;
Again your patch seems to be not formatted correctly. Please use some decent parameter for patch creation via "diff" or use the git (or cogito) commands for patch creation (which is actually preferred).
I assume this will unfortunately be the case for all the patches you dent today. Please resubmit in a propper way.
Thanks.
Best regards,
Stefan
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================