diff options
author | Richard Weinberger <richard@nod.at> | 2016-06-14 10:12:16 +0200 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2016-07-29 23:32:43 +0200 |
commit | 5283ec72b0cca44ccea63070f6954fd8675b9ac4 (patch) | |
tree | 61705317853d1d51a6de1b6a83f5f43ef43b75c7 /drivers/mtd | |
parent | fdf10ed710c0aa177e8dfcd84e65e4e5e8e0956b (diff) | |
download | linux-5283ec72b0cca44ccea63070f6954fd8675b9ac4.tar.bz2 |
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>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/ubi/fastmap.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c index 12bdb0902327..b66cb3e2a5f0 100644 --- a/drivers/mtd/ubi/fastmap.c +++ b/drivers/mtd/ubi/fastmap.c @@ -975,6 +975,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)", |