]> www.infradead.org Git - mtd-utils.git/commitdiff
nandflipbits: fix corrupted oob
authorChristophe Kerello <christophe.kerello@foss.st.com>
Thu, 16 Jun 2022 07:39:43 +0000 (09:39 +0200)
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>
Mon, 27 Jun 2022 05:58:48 +0000 (07:58 +0200)
If a bit is flipped in block 1 or higher, the OOB is corrupted with the
OOB of block 0. Mtd_read_oob API has to take into account the block number
to be able to calculate the right offset.

Fixes: 9fc8db29cf62 ("mtd-utils: Add nandflipbits tool")
Signed-off-by: Christophe Kerello <christophe.kerello@foss.st.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
nand-utils/nandflipbits.c

index aa6850fe16c9f517bee742a561572bcfd31cfbaf..cd66d0baa8a3b55d5175c54201fe29045cc01622 100644 (file)
@@ -249,7 +249,9 @@ int main(int argc, char **argv)
 
                        bufoffs += mtd.min_io_size;
 
-                       ret = mtd_read_oob(mtd_desc, &mtd, fd, blkoffs,
+                       ret = mtd_read_oob(mtd_desc, &mtd, fd,
+                                          bit_to_flip->block * mtd.eb_size +
+                                          blkoffs,
                                           mtd.oob_size, buffer + bufoffs);
                        if (ret) {
                                fprintf(stderr, "MTD OOB read failure\n");