From: Stanley.Miao Date: Tue, 18 May 2010 12:23:10 +0000 (+0800) Subject: nandwrite: check if the start address is page-aligned X-Git-Tag: v1.4.0~46 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=a8214921bdc7d78b75d133a37ff9f8d4ec919650;p=mtd-utils.git nandwrite: check if the start address is page-aligned Only page-aligned address is permitted in NAND subsystem. Signed-off-by: Stanley.Miao Signed-off-by: Artem Bityutskiy --- diff --git a/nandwrite.c b/nandwrite.c index 1e30ad1..e691ebd 100644 --- a/nandwrite.c +++ b/nandwrite.c @@ -307,6 +307,14 @@ int main(int argc, char * const argv[]) exit (EXIT_FAILURE); } + if (mtdoffset & (meminfo.writesize - 1)) { + fprintf(stderr, "The start address is not page-aligned !\n" + "The pagesize of this NAND Flash is 0x%x.\n", + meminfo.writesize); + close(fd); + exit(EXIT_FAILURE); + } + if (autoplace) { /* Read the current oob info */ if (ioctl (fd, MEMGETOOBSEL, &old_oobinfo) != 0) {