UBI: Call scan_all() with correct offset in error case
authorRichard Weinberger <richard@nod.at>
Sat, 28 Sep 2013 13:55:12 +0000 (15:55 +0200)
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Thu, 3 Oct 2013 16:42:49 +0000 (19:42 +0300)
If we find an invalid fastmap we have to scan from the very beginning.
Otherwise we leak the first 64 PEBs.

Reported-and-tested-by: Richard Genoud <richard.genoud@gmail.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
drivers/mtd/ubi/attach.c

index c071d41..03b32b0 100644 (file)
@@ -1417,9 +1417,11 @@ int ubi_attach(struct ubi_device *ubi, int force_scan)
                                ai = alloc_ai("ubi_aeb_slab_cache2");
                                if (!ai)
                                        return -ENOMEM;
-                       }
 
-                       err = scan_all(ubi, ai, UBI_FM_MAX_START);
+                               err = scan_all(ubi, ai, 0);
+                       } else {
+                               err = scan_all(ubi, ai, UBI_FM_MAX_START);
+                       }
                }
        }
 #else