summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2017-04-07 09:59:38 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2017-04-07 09:59:38 +0200
commit9a844e93771bdc00b37177619de04fb0e4a2432b (patch)
tree033c400be03ec05aeb0510b428d0574147c3ec04
parent4cd023c77942f48efded3e9e47c2be823d5c8d82 (diff)
parenta8ef43b995fcd4c92edbf9492ac0378f8dc2441a (diff)
downloadbarebox-9a844e93771bdc00b37177619de04fb0e4a2432b.tar.gz
barebox-9a844e93771bdc00b37177619de04fb0e4a2432b.tar.xz
Merge branch 'for-next/mtd'
-rw-r--r--commands/nand-bitflip.c4
-rw-r--r--drivers/mtd/peb.c4
2 files changed, 7 insertions, 1 deletions
diff --git a/commands/nand-bitflip.c b/commands/nand-bitflip.c
index fe56f222cf..a8a97c153a 100644
--- a/commands/nand-bitflip.c
+++ b/commands/nand-bitflip.c
@@ -69,6 +69,10 @@ static int do_nand_bitflip(int argc, char *argv[])
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 66227d4ffb..c35b63f2fd 100644
--- a/drivers/mtd/peb.c
+++ b/drivers/mtd/peb.c
@@ -565,6 +565,8 @@ int mtd_peb_create_bitflips(struct mtd_info *mtd, int pnum, int offset,
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 @@ int mtd_peb_create_bitflips(struct mtd_info *mtd, int pnum, int offset,
for (i = 0; i < num_bitflips; i++) {
int offs;
int bit;
- u8 *pos = buf;
+ u8 *pos = buf + offset;
if (random) {
offs = random32() % len;