]> www.infradead.org Git - mtd-utils.git/commitdiff
nandwrite: check if the start address is page-aligned
authorStanley.Miao <stanley.miao@windriver.com>
Tue, 18 May 2010 12:23:10 +0000 (20:23 +0800)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Sat, 22 May 2010 05:37:55 +0000 (08:37 +0300)
Only page-aligned address is permitted in NAND subsystem.

Signed-off-by: Stanley.Miao <stanley.miao@windriver.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
nandwrite.c

index 1e30ad1943932a6165b013331b8a9b7b3a0d9aee..e691ebd4207063e880aa9cef248349aedcbbe801 100644 (file)
@@ -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) {