diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index e292d2b..d0fbbb0 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -712,10 +712,6 @@ static int flash_read_buf (int dev, int fd, void *buf, size_t count,
 
 	/* This only runs once on NOR flash */
 	while (processed < count) {
-		rc = flash_bad_block (fd, mtd_type, &blockstart);
-		if (rc < 0)		/* block test failed */
-			return -1;
-
 		if (blockstart + block_seek + readlen > top_of_range) {
 			/* End of range is reached */
 			fprintf (stderr,
@@ -723,6 +719,10 @@ static int flash_read_buf (int dev, int fd, void *buf, size_t count,
 			return -1;
 		}
 
+		rc = flash_bad_block (fd, mtd_type, &blockstart);
+		if (rc < 0)		/* block test failed */
+			return -1;
+
 		if (rc) {		/* block is bad */
 			blockstart += blocklen;
 			continue;
@@ -845,15 +845,15 @@ static int flash_write_buf (int dev, int fd, void *buf, size_t count,
 
 	/* This only runs once on NOR flash and SPI-dataflash */
 	while (processed < write_total) {
-		rc = flash_bad_block (fd, mtd_type, &blockstart);
-		if (rc < 0)		/* block test failed */
-			return rc;
-
 		if (blockstart + erasesize > top_of_range) {
 			fprintf (stderr, "End of range reached, aborting\n");
 			return -1;
 		}
 
+		rc = flash_bad_block (fd, mtd_type, &blockstart);
+		if (rc < 0)		/* block test failed */
+			return rc;
+
 		if (rc) {		/* block is bad */
 			blockstart += blocklen;
 			continue;
