[01/23] UBI: Fastmap: Fix EC overflow calculation

Submitted by Richard Weinberger on June 1, 2012, 3:16 p.m.

Details

Message ID 1338563804-85990-2-git-send-email-richard@nod.at
State New, archived
Headers show

Commit Message

Richard Weinberger June 1, 2012, 3:16 p.m.
Checking for an overflow without a be64_to_cpu() make no sense...

Signed-off-by: Richard Weinberger <richard@nod.at>
---
 drivers/mtd/ubi/fastmap.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

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);