The 'erasesize' used to compute 'block_offset' in 'mtd_fixtrx' (imagetag.c) is
used before it is computed by 'mtd_check_open'; moving the call to 
'mtd_check_open'
up a few lines fixes this.

A similar problem in 'trx.c' was fixed in 
https://dev.openwrt.org/changeset/32866 .

I do not have the H/W to test this patch.

Nathan

Index: package/mtd/src/imagetag.c
===================================================================
--- package/mtd/src/imagetag.c  (revision 35318)
+++ package/mtd/src/imagetag.c  (working copy)
@@ -211,15 +211,15 @@
        if (quiet < 2)
                fprintf(stderr, "Trying to fix trx header in %s at 0x%x...\n", 
mtd, offset);
 
-       block_offset = offset & ~(erasesize - 1);
-       offset -= block_offset;
-
        fd = mtd_check_open(mtd);
        if(fd < 0) {
                fprintf(stderr, "Could not open mtd device: %s\n", mtd);
                exit(1);
        }
 
+       block_offset = offset & ~(erasesize - 1);
+       offset -= block_offset;
+
        if (block_offset + erasesize > mtdsize) {
                fprintf(stderr, "Offset too large, device size 0x%x\n", 
mtdsize);
                exit(1);

_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to