Skip to content

Commit 32bc482

Browse files
Adrian HunterArtem Bityutskiy
authored andcommitted
UBI: compatible fallback in absense of sequence numbers
Fall back onto thinking everything's OK if either of the sequence numbers we are asked to compare is zero, which is what was used before sequence numbers were introduced. [ Artem: modified the patch to be applicable to upstream UBI, added big comment ] Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com> Signed-off-by: Phil Carmody <ext-phil.2.carmody@nokia.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
1 parent 7194e6f commit 32bc482

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

‎drivers/mtd/ubi/scan.c‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,11 +781,22 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si,
781781
return -EINVAL;
782782
}
783783

784+
/*
785+
* Make sure that all PEBs have the same image sequence number.
786+
* This allows us to detect situations when users flash UBI
787+
* images incorrectly, so that the flash has the new UBI image
788+
* and leftovers from the old one. This feature was added
789+
* relatively recently, and the sequence number was always
790+
* zero, because old UBI implementations always set it to zero.
791+
* For this reasons, we do not panic if some PEBs have zero
792+
* sequence number, while other PEBs have non-zero sequence
793+
* number.
794+
*/
784795
image_seq = be32_to_cpu(ech->image_seq);
785796
if (!si->image_seq_set) {
786797
ubi->image_seq = image_seq;
787798
si->image_seq_set = 1;
788-
} else if (ubi->image_seq != image_seq) {
799+
} else if (ubi->image_seq && ubi->image_seq != image_seq) {
789800
ubi_err("bad image sequence number %d in PEB %d, "
790801
"expected %d", image_seq, pnum, ubi->image_seq);
791802
ubi_dbg_dump_ec_hdr(ech);

0 commit comments

Comments
 (0)