Skip to contentSkip to conversation

nand: Fix access to last block in NAND devices

PATCH New Stefan Roese 2 participants 2 messages Dec 9, 2009 – Dec 11, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nand: Fix access to last block in NAND devices

Currently, the last block of NAND devices can't be accessed. This patch fixes this issue by correcting the boundary checking (off-by-one error).

Cc Scott Wood <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 drivers/mtd/nand/nand_util.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/mtd/nand/nand_util.c +2 -2
index 7085d42..61bf7e6 100644
@@ -490,7 +490,7 @@ int nand_write_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
 
 	len_incl_bad = get_len_incl_bad (nand, offset, *length);
 
-	if ((offset + len_incl_bad) >= nand->size) {
+	if ((offset + len_incl_bad) > nand->size) {
 		printf ("Attempt to write outside the flash area\n");
 		return -EINVAL;
 	}
@@ -562,7 +562,7 @@ int nand_read_skip_bad(nand_info_t *nand, loff_t offset, size_t *length,
 
 	len_incl_bad = get_len_incl_bad (nand, offset, *length);
 
-	if ((offset + len_incl_bad) >= nand->size) {
+	if ((offset + len_incl_bad) > nand->size) {
 		printf ("Attempt to read outside the flash area\n");
 		return -EINVAL;
 	}
Signature · 1 line
1.6.6.rc1
#1 lore raw

PATCH 1/1 nand: Fix access to last block in NAND devices

Quoted 9 lines · Stefan Roese

Currently, the last block of NAND devices can't be accessed. This patch fixes this issue by correcting the boundary checking (off-by-one error).

Cc Scott Wood <[email protected]>
Cc Wolfgang Denk <[email protected]>
---
 drivers/mtd/nand/nand_util.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Applied to u-boot-nand-flash.

-Scott