Skip to contentSkip to conversation

cmd_jffs2: Fix get_part_sector_size_nor() overflow bug

PATCH New Peter Tyser 2 participants 2 messages Dec 30, 2010 – Jan 18, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cmd_jffs2: Fix get_part_sector_size_nor() overflow bug

When a flash partition was positioned at the very top of a 32-bit memory map (eg located at 0xf8000000 with a size of 0x8000000) get_part_sector_size_nor() would incorrectly calculate the partition's ending address to 0x0 due to overflow. When the overflow occurred get_part_sector_size_nor() would falsely return a sector size of 0. A sector size of 0 results in subsequent jffs2 operations failing.

To workaround the overflow subtract 1 from calculated address of the partition endpoint.

---
 common/cmd_jffs2.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
common/cmd_jffs2.c +1 -1
index 0e7a6b0..27296dd 100644
@@ -281,7 +281,7 @@ static inline u32 get_part_sector_size_nor(struct mtdids *id, struct part_info *
 	flash = &flash_info[id->num];
 
 	start_phys = flash->start[0] + part->offset;
-	end_phys = start_phys + part->size;
+	end_phys = start_phys + part->size - 1;
 
 	for (i = 0; i < flash->sector_count; i++) {
 		if (flash->start[i] >= end_phys)
Signature · 1 line
1.7.0.4
#1 lore raw

PATCH 1/1 cmd_jffs2: Fix get_part_sector_size_nor() overflow bug

Dear Peter Tyser,

Quoted 7 lines · In message <[email protected]> you wrote:

When a flash partition was positioned at the very top of a 32-bit memory map (eg located at 0xf8000000 with a size of 0x8000000) get_part_sector_size_nor() would incorrectly calculate the partition's ending address to 0x0 due to overflow. When the overflow occurred get_part_sector_size_nor() would falsely return a sector size of 0. A sector size of 0 results in subsequent jffs2 operations failing.

Quoted 7 lines

To workaround the overflow subtract 1 from calculated address of the partition endpoint.

---
 common/cmd_jffs2.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Applied.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I am a computer. I am dumber than any human and smarter than any  ad-
ministrator.