Account the offset_start in the bounds check of the for loop. This was
previously missing, differing in check and actual read.
Signed-off-by: David Bauer <mail@david-bauer.net>
hdr_len = sizeof(struct fdt_header);
/* Parse the MTD device & search for the FIT image location */
- for(offset = 0; offset + hdr_len <= mtd->size; offset += mtd->erasesize) {
+ for (offset = 0; offset + offset_start + hdr_len <= mtd->size; offset += mtd->erasesize) {
ret = mtd_read(mtd, offset + offset_start, hdr_len, &retlen, (void*) &hdr);
if (ret) {
pr_err("read error in \"%s\" at offset 0x%llx\n",