diff mbox

[U-Boot] cmd_jffs2: Fix get_part_sector_size_nor() overflow bug

Message ID 1293745676-1557-1-git-send-email-ptyser@xes-inc.com
State Accepted
Commit 141053d60ac459bc3859c06fe7cf16160077f937
Headers show

Commit Message

Peter Tyser Dec. 30, 2010, 9:47 p.m. UTC
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.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
---
 common/cmd_jffs2.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Wolfgang Denk Jan. 18, 2011, 11:05 p.m. UTC | #1
Dear Peter Tyser,

In message <1293745676-1557-1-git-send-email-ptyser@xes-inc.com> 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.
> 
> To workaround the overflow subtract 1 from calculated address of
> the partition endpoint.
> 
> Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
> ---
>  common/cmd_jffs2.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)

Applied.

Best regards,

Wolfgang Denk
diff mbox

Patch

diff --git a/common/cmd_jffs2.c b/common/cmd_jffs2.c
index 0e7a6b0..27296dd 100644
--- a/common/cmd_jffs2.c
+++ b/common/cmd_jffs2.c
@@ -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)