diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index 533b1a4..7ed5c4f 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -763,6 +763,9 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
 			return UBI_IO_PEB_EMPTY;
 		}
 
+		if (read_err == -EBADMSG)
+			return UBI_IO_BAD_READ;
+
 		/*
 		 * This is not a valid erase counter header, and these are not
 		 * 0xFF bytes. Report that the header is corrupted.
@@ -1034,6 +1037,9 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum,
 			return UBI_IO_PEB_FREE;
 		}
 
+		if (read_err == -EBADMSG)
+			return UBI_IO_BAD_READ;
+
 		/*
 		 * This is not a valid VID header, and these are not 0xFF
 		 * bytes. Report that the header is corrupted.
diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index 48e570c..99ed225 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -745,7 +745,7 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si,
 		bitflips = 1;
 	else if (err == UBI_IO_PEB_EMPTY)
 		return add_to_list(si, pnum, UBI_SCAN_UNKNOWN_EC, &si->erase);
-	else if (err == UBI_IO_BAD_EC_HDR) {
+	else if (err == UBI_IO_BAD_EC_HDR || err = UBI_IO_BAD_READ) {
 		/*
 		 * We have to also look at the VID header, possibly it is not
 		 * corrupted. Set %bitflips flag in order to make this PEB be
@@ -756,11 +756,12 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si,
 		bitflips = 1;
 	}
 
+	if (err != UBI_IO_BAD_READ)
+		si->is_empty = 0;
+
 	if (!ec_corr) {
 		int image_seq;
 
-		/* There is an EC header, so the flash is not empty */
-		si->is_empty = 0;
 
 		/* Make sure UBI version is OK */
 		if (ech->version != UBI_VERSION) {
@@ -814,7 +815,7 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si,
 		return err;
 	else if (err == UBI_IO_BITFLIPS)
 		bitflips = 1;
-	else if (err == UBI_IO_BAD_VID_HDR ||
+	else if (err == UBI_IO_BAD_VID_HDR || err == UBI_IO_BAD_READ ||
 		 (err == UBI_IO_PEB_FREE && ec_corr)) {
 		/* VID header is corrupted */
 		err = add_to_list(si, pnum, ec, &si->corr);
@@ -828,7 +829,8 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si,
 			return err;
 		goto adjust_mean_ec;
 	}
-	si->is_empty = 0;
+	if (err != UBI_IO_BAD_READ)
+		si->is_empty = 0;
 
 	vol_id = be32_to_cpu(vidh->vol_id);
 	if (vol_id > UBI_MAX_VOLUMES && vol_id != UBI_LAYOUT_VOLUME_ID) {
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index a637f02..dd8467e 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -99,6 +99,7 @@ enum {
 	UBI_IO_PEB_FREE,
 	UBI_IO_BAD_EC_HDR,
 	UBI_IO_BAD_VID_HDR,
+	UBI_IO_BAD_READ,
 	UBI_IO_BITFLIPS
 };
 
