Skip to content

Commit

Permalink
UBI: fix backward compatibility
Browse files Browse the repository at this point in the history
Commit 32bc482 did not fully fix
the backward compatibility issues. We still fail to properly handle
situations when the first PEB contains non-zero image sequence
number, but one of the following PEBs contains zero image sequence
number. For example, this may happen if we mount a new image with
an old kernel, and then try to mount it in the new kernel.

This patch should fix the issue.

Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
  • Loading branch information
Artem Bityutskiy authored and Artem Bityutskiy committed Oct 20, 2009
1 parent 012abee commit 2eadaad
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 3 additions & 4 deletions drivers/mtd/ubi/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -794,16 +794,15 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si,
* number.
*/
image_seq = be32_to_cpu(ech->image_seq);
if (!si->image_seq_set) {
if (!ubi->image_seq && image_seq)
ubi->image_seq = image_seq;
si->image_seq_set = 1;
} else if (ubi->image_seq && ubi->image_seq != image_seq) {
if (ubi->image_seq && image_seq &&
ubi->image_seq != image_seq) {
ubi_err("bad image sequence number %d in PEB %d, "
"expected %d", image_seq, pnum, ubi->image_seq);
ubi_dbg_dump_ec_hdr(ech);
return -EINVAL;
}

}

/* OK, we've done with the EC header, let's look at the VID header */
Expand Down
2 changes: 0 additions & 2 deletions drivers/mtd/ubi/scan.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ struct ubi_scan_volume {
* @ec_sum: a temporary variable used when calculating @mean_ec
* @ec_count: a temporary variable used when calculating @mean_ec
* @corr_count: count of corrupted PEBs
* @image_seq_set: indicates @ubi->image_seq is known
*
* This data structure contains the result of scanning and may be used by other
* UBI sub-systems to build final UBI data structures, further error-recovery
Expand All @@ -127,7 +126,6 @@ struct ubi_scan_info {
uint64_t ec_sum;
int ec_count;
int corr_count;
int image_seq_set;
};

struct ubi_device;
Expand Down

0 comments on commit 2eadaad

Please sign in to comment.