[PATCH 01/23] UBI: Fastmap: Fix EC overflow calculation
Richard Weinberger
richard at nod.at
Fri Jun 1 11:16:22 EDT 2012
Checking for an overflow without a be64_to_cpu() make no sense...
Signed-off-by: Richard Weinberger <richard at nod.at>
---
drivers/mtd/ubi/fastmap.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
index 2ba2a80..56479df 100644
--- a/drivers/mtd/ubi/fastmap.c
+++ b/drivers/mtd/ubi/fastmap.c
@@ -1163,6 +1163,7 @@ int ubi_update_fastmap(struct ubi_device *ubi)
/* no fresh early PEB was found, reuse the old one */
if (new_fm->e[0]->pnum < 0) {
struct ubi_ec_hdr *ec_hdr;
+ long long ec;
ec_hdr = kzalloc(ubi->ec_hdr_alsize, GFP_KERNEL);
if (!ec_hdr) {
@@ -1193,8 +1194,9 @@ int ubi_update_fastmap(struct ubi_device *ubi)
return ret;
}
- ec_hdr->ec += ret;
- if (ec_hdr->ec > UBI_MAX_ERASECOUNTER) {
+ ec = be64_to_cpu(ec_hdr->ec);
+ ec += ret;
+ if (ec > UBI_MAX_ERASECOUNTER) {
ubi_err("Erase counter overflow!");
kfree(new_fm);
kfree(ec_hdr);
--
1.7.6.5
More information about the linux-mtd
mailing list