diff options
| -rw-r--r-- | drivers/mtd/ubi/fastmap.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c index 9b42add0553c..05067f522476 100644 --- a/drivers/mtd/ubi/fastmap.c +++ b/drivers/mtd/ubi/fastmap.c | |||
| @@ -407,6 +407,7 @@ static int scan_pool(struct ubi_device *ubi, struct ubi_attach_info *ai, | |||
| 407 | */ | 407 | */ |
| 408 | for (i = 0; i < pool_size; i++) { | 408 | for (i = 0; i < pool_size; i++) { |
| 409 | int scrub = 0; | 409 | int scrub = 0; |
| 410 | int image_seq; | ||
| 410 | 411 | ||
| 411 | pnum = be32_to_cpu(pebs[i]); | 412 | pnum = be32_to_cpu(pebs[i]); |
| 412 | 413 | ||
| @@ -425,7 +426,13 @@ static int scan_pool(struct ubi_device *ubi, struct ubi_attach_info *ai, | |||
| 425 | } else if (ret == UBI_IO_BITFLIPS) | 426 | } else if (ret == UBI_IO_BITFLIPS) |
| 426 | scrub = 1; | 427 | scrub = 1; |
| 427 | 428 | ||
| 428 | if (be32_to_cpu(ech->image_seq) != ubi->image_seq) { | 429 | /* |
| 430 | * Older UBI implementations have image_seq set to zero, so | ||
| 431 | * we shouldn't fail if image_seq == 0. | ||
| 432 | */ | ||
| 433 | image_seq = be32_to_cpu(ech->image_seq); | ||
| 434 | |||
| 435 | if (image_seq && (image_seq != ubi->image_seq)) { | ||
| 429 | ubi_err("bad image seq: 0x%x, expected: 0x%x", | 436 | ubi_err("bad image seq: 0x%x, expected: 0x%x", |
| 430 | be32_to_cpu(ech->image_seq), ubi->image_seq); | 437 | be32_to_cpu(ech->image_seq), ubi->image_seq); |
| 431 | ret = UBI_BAD_FASTMAP; | 438 | ret = UBI_BAD_FASTMAP; |
| @@ -923,6 +930,8 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai, | |||
| 923 | } | 930 | } |
| 924 | 931 | ||
| 925 | for (i = 0; i < used_blocks; i++) { | 932 | for (i = 0; i < used_blocks; i++) { |
| 933 | int image_seq; | ||
| 934 | |||
| 926 | pnum = be32_to_cpu(fmsb->block_loc[i]); | 935 | pnum = be32_to_cpu(fmsb->block_loc[i]); |
| 927 | 936 | ||
| 928 | if (ubi_io_is_bad(ubi, pnum)) { | 937 | if (ubi_io_is_bad(ubi, pnum)) { |
| @@ -940,10 +949,17 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai, | |||
| 940 | } else if (ret == UBI_IO_BITFLIPS) | 949 | } else if (ret == UBI_IO_BITFLIPS) |
| 941 | fm->to_be_tortured[i] = 1; | 950 | fm->to_be_tortured[i] = 1; |
| 942 | 951 | ||
| 952 | image_seq = be32_to_cpu(ech->image_seq); | ||
| 943 | if (!ubi->image_seq) | 953 | if (!ubi->image_seq) |
| 944 | ubi->image_seq = be32_to_cpu(ech->image_seq); | 954 | ubi->image_seq = image_seq; |
| 945 | 955 | ||
| 946 | if (be32_to_cpu(ech->image_seq) != ubi->image_seq) { | 956 | /* |
| 957 | * Older UBI implementations have image_seq set to zero, so | ||
| 958 | * we shouldn't fail if image_seq == 0. | ||
| 959 | */ | ||
| 960 | if (image_seq && (image_seq != ubi->image_seq)) { | ||
| 961 | ubi_err("wrong image seq:%d instead of %d", | ||
| 962 | be32_to_cpu(ech->image_seq), ubi->image_seq); | ||
| 947 | ret = UBI_BAD_FASTMAP; | 963 | ret = UBI_BAD_FASTMAP; |
| 948 | goto free_hdr; | 964 | goto free_hdr; |
| 949 | } | 965 | } |
