@@ -1333,8 +1333,11 @@ int ubi_attach(struct ubi_device *ubi, int force_scan)
goto out_wl;
}
- self_check_eba(ubi, ai, scan_ai);
+ err = self_check_eba(ubi, ai, scan_ai);
destroy_ai(ubi, scan_ai);
+
+ if (err)
+ goto out_wl;
}
destroy_ai(ubi, ai);
@@ -1223,7 +1223,9 @@ static void print_rsvd_warning(struct ubi_device *ubi,
* @ai_fastmap: UBI attach info object created by fastmap
* @ai_scan: UBI attach info object created by scanning
*
- * TODO: what we do and what return.
+ * Returns < 0 in case of an internal error, 0 otherwise.
+ * If a bad EBA table entry was found it will be printed out and
+ * ubi_assert() triggers.
*/
int self_check_eba(struct ubi_device *ubi, struct ubi_attach_info *ai_fastmap,
struct ubi_attach_info *ai_scan)
@@ -1291,8 +1293,7 @@ int self_check_eba(struct ubi_device *ubi, struct ubi_attach_info *ai_fastmap,
ubi_err("LEB:%i:%i is PEB:%i instead of %i!",
vol->vol_id, i, fm_eba[i][j], scan_eba[i][j]);
- /* TODO: no, please, return error instead */
- BUG();
+ ubi_assert(0);
}
}
}
Don't BUG() on error and document return values. Signed-off-by: Richard Weinberger <richard@nod.at> --- drivers/mtd/ubi/attach.c | 5 ++++- drivers/mtd/ubi/eba.c | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-)