]> www.infradead.org Git - mtd-utils.git/commit
mtd-utils: Check mtdoffset is not larger than mtd.size in case of a bad block.
authorTomer Barletz <barletz@gmail.com>
Tue, 26 Jun 2012 21:46:41 +0000 (14:46 -0700)
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Fri, 29 Jun 2012 08:29:26 +0000 (11:29 +0300)
commitd7f1b2f9abde75b88e69490d619857c82e7e3517
tree9c27a34eb16ec25713f65154819291a165829089
parent5625ce5e25bcdc04603a4e44f228fe4a3586e77a
mtd-utils: Check mtdoffset is not larger than mtd.size in case of a bad block.

mtdoffset is being tested against mtd.size in the outer two loops, but
the third nested one does not test against it.
In case of a bad block we'll try to access an out of bounds offset in
the next MEMGETBADBLOCK ioctl, which will fail with EINVAL.
In case mtdoffset is indeed larger than the partition size, we need to
bail, since there are not enough "good" blocks to complete the write.

Signed-off-by: Tomer Barletz <barletz@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
nandwrite.c