summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi
diff options
context:
space:
mode:
authorRichard Weinberger <richard@nod.at>2018-08-29 14:19:32 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2018-08-31 08:23:29 +0200
commitb9eedf1a83b1436c15aa43ef5cd4c99669f666dd (patch)
tree62802501e6fdb3e72324620e3b0d4801c87dc159 /drivers/mtd/ubi
parentf70cee7bcc1b09eff9f277e0913b70fc87418d47 (diff)
downloadbarebox-b9eedf1a83b1436c15aa43ef5cd4c99669f666dd.tar.gz
barebox-b9eedf1a83b1436c15aa43ef5cd4c99669f666dd.tar.xz
ubi: Check whether the Fastmap anchor matches the super block
This helps to detect cases where an user copies an UBI image to another target with different bad blocks. Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Teresa Remmet <t.remmet@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/mtd/ubi')
-rw-r--r--drivers/mtd/ubi/fastmap.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
index 4a8de1db40..d60f89fdb3 100644
--- a/drivers/mtd/ubi/fastmap.c
+++ b/drivers/mtd/ubi/fastmap.c
@@ -908,6 +908,13 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai,
goto free_hdr;
}
+ if (i == 0 && pnum != fm_anchor) {
+ ubi_err(ubi, "Fastmap anchor PEB mismatch: PEB: %i vs. %i",
+ pnum, fm_anchor);
+ ret = UBI_BAD_FASTMAP;
+ goto free_hdr;
+ }
+
ret = ubi_io_read_ec_hdr(ubi, pnum, ech, 0);
if (ret && ret != UBI_IO_BITFLIPS) {
ubi_err(ubi, "unable to read fastmap block# %i EC (PEB: %i)",