UBIFS: fix the dark space calculation
authorsrimugunthan dhandapani <srimugunthan.dhandapani@gmail.com>
Fri, 26 Aug 2011 10:38:39 +0000 (16:08 +0530)
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Fri, 26 Aug 2011 10:38:39 +0000 (16:08 +0530)
The dark space calculation should be 64 bit type-casted, when
assigning to tmp64 (similar to how total_free is calculated).
Overflow will occur for very large flashes.

Signed-off-by: srimugunthan <srimugunthan.dhandapani@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
fs/ubifs/recovery.c
fs/ubifs/sb.c

index af02790d93282ec55c3ba48c3efca155b5ddea89..ee4f43f4bb998d2bc20ac1f96437e926e2f2e490 100644 (file)
@@ -983,7 +983,7 @@ int ubifs_recover_inl_heads(struct ubifs_info *c, void *sbuf)
 }
 
 /**
- *  clean_an_unclean_leb - read and write a LEB to remove corruption.
+ * clean_an_unclean_leb - read and write a LEB to remove corruption.
  * @c: UBIFS file-system description object
  * @ucleb: unclean LEB information
  * @sbuf: LEB-sized buffer to use
index 93d938ad3d2a74ec74d56a5d64aba6860a44eb10..6094c5a5d7a8de597e3905b9c4941f458cc999f3 100644 (file)
@@ -247,7 +247,7 @@ static int create_default_filesystem(struct ubifs_info *c)
        mst->total_dirty = cpu_to_le64(tmp64);
 
        /*  The indexing LEB does not contribute to dark space */
-       tmp64 = (c->main_lebs - 1) * c->dark_wm;
+       tmp64 = ((long long)(c->main_lebs - 1) * c->dark_wm);
        mst->total_dark = cpu_to_le64(tmp64);
 
        mst->total_used = cpu_to_le64(UBIFS_INO_NODE_SZ);