kernel: Correctly search for the FIT image in mtd partition.
authorFredrik Olofsson <fredrik.olofsson@anyfinetworks.com>
Wed, 4 Sep 2019 08:41:22 +0000 (10:41 +0200)
committerRISCi_ATOM <bob@bobcall.me>
Thu, 10 Oct 2019 15:54:30 +0000 (11:54 -0400)
Previously all iterations of the loop checked offset=0 in the partition.

Signed-off-by: Fredrik Olofsson <fredrik.olofsson@anyfinetworks.com>
(cherry picked from commit dc76900021b880820adf981bb7b1cf5ff3ffe1fd)

target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_fit.c

index f9e5e53a951b5d0dad19d6212ab56a85402471f0..d206fecd5b197454a79babfbf770644b54da0bde 100644 (file)
@@ -60,8 +60,8 @@ mtdsplit_fit_parse(struct mtd_info *mtd,
        hdr_len = sizeof(struct fdt_header);
 
        /* Parse the MTD device & search for the FIT image location */
-       for(offset = 0; offset < mtd->size; offset += mtd->erasesize) {
-               ret = mtd_read(mtd, 0, hdr_len, &retlen, (void*) &hdr);
+       for(offset = 0; offset + hdr_len < mtd->size; offset += mtd->erasesize) {
+               ret = mtd_read(mtd, offset, hdr_len, &retlen, (void*) &hdr);
                if (ret) {
                        pr_err("read error in \"%s\" at offset 0x%llx\n",
                               mtd->name, (unsigned long long) offset);