aboutsummaryrefslogtreecommitdiffstats
path: root/package/mtd/src/trx.c
diff options
context:
space:
mode:
Diffstat (limited to 'package/mtd/src/trx.c')
-rw-r--r--package/mtd/src/trx.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/package/mtd/src/trx.c b/package/mtd/src/trx.c
index d1aab36923..65c24404c2 100644
--- a/package/mtd/src/trx.c
+++ b/package/mtd/src/trx.c
@@ -154,15 +154,15 @@ mtd_fixtrx(const char *mtd, size_t offset)
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);