UBI: add sanity check

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Sun Feb 3 06:59:02 EST 2008


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=64203195edf44601d9825284101dcaf7ad54ece8
Commit:     64203195edf44601d9825284101dcaf7ad54ece8
Parent:     2f9270e7fe86591d6ba01c0df6ad3f6c035687ea
Author:     Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
AuthorDate: Tue Jan 22 12:38:15 2008 +0200
Committer:  Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
CommitDate: Fri Jan 25 16:41:25 2008 +0200

    UBI: add sanity check
    
    Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy at nokia.com>
---
 drivers/mtd/ubi/scan.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index 0c05f7b..e476638 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -286,9 +286,14 @@ static int compare_lebs(struct ubi_device *ubi, const struct ubi_scan_leb *seb,
 		 * FIXME: but this is anyway obsolete and will be removed at
 		 * some point.
 		 */
-
 		dbg_bld("using old crappy leb_ver stuff");
 
+		if (v1 == v2) {
+			ubi_err("PEB %d and PEB %d have the same version %lld",
+				seb->pnum, pnum, v1);
+			return -EINVAL;
+		}
+
 		abs = v1 - v2;
 		if (abs < 0)
 			abs = -abs;



More information about the linux-mtd-cvs mailing list