From: Christophe Kerello Date: Thu, 16 Jun 2022 07:39:43 +0000 (+0200) Subject: nandflipbits: fix corrupted oob X-Git-Tag: v2.1.5~8 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=a315011bd3c237660436e0c796743d61acf4a7b6;p=mtd-utils.git nandflipbits: fix corrupted oob 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 Signed-off-by: David Oberhollenzer --- diff --git a/nand-utils/nandflipbits.c b/nand-utils/nandflipbits.c index aa6850f..cd66d0b 100644 --- a/nand-utils/nandflipbits.c +++ b/nand-utils/nandflipbits.c @@ -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");