diff --git a/commands/nand-bitflip.c b/commands/nand-bitflip.c index fe56f22..a8a97c1 100644 --- a/commands/nand-bitflip.c +++ b/commands/nand-bitflip.c @@ -69,6 +69,10 @@ block += mtd_div_by_eb(offset, meminfo.mtd); offset = mtd_mod_by_eb(offset, meminfo.mtd); + if ((int)offset % meminfo.mtd->writesize) { + printf("offset has to be pagesize aligned\n"); + return 1; + } if (!check) { ret = mtd_peb_create_bitflips(meminfo.mtd, block, offset, meminfo.writesize, diff --git a/drivers/mtd/peb.c b/drivers/mtd/peb.c index 66227d4..c35b63f 100644 --- a/drivers/mtd/peb.c +++ b/drivers/mtd/peb.c @@ -565,6 +565,8 @@ if (offset < 0 || offset + len > mtd->erasesize) return -EINVAL; + if (offset % mtd->writesize) + return -EINVAL; if (len <= 0) return -EINVAL; if (num_bitflips <= 0) @@ -610,7 +612,7 @@ for (i = 0; i < num_bitflips; i++) { int offs; int bit; - u8 *pos = buf; + u8 *pos = buf + offset; if (random) { offs = random32() % len;