aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem B. Bityutskiy <dedekind@infradead.org>2005-08-17 10:57:43 -0400
committerThomas Gleixner <tglx@mtd.linutronix.de>2005-11-06 14:29:56 -0500
commit280562b2104c9a0ca7efc5e716b6452a7ba820fa (patch)
tree6dcee70d0ec3da6fbb8afd9e05e6b73c1a46e97a
parent8d5df40954281a8e0f788b311f9c08f96e530ffa (diff)
[JFFS2] Calculate CRC check starting point correctly
When data starts from the beginning of NAND page, 'len' must be zero, not c->wbuf_page. Thanks to Zoltan Sogor for reporting this problem. Signed-off-by: Artem B. Bityutskiy <dedekind@infradead.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r--fs/jffs2/nodelist.c5
-rw-r--r--fs/jffs2/readinode.c12
2 files changed, 9 insertions, 8 deletions
diff --git a/fs/jffs2/nodelist.c b/fs/jffs2/nodelist.c
index 0393d27eafc7..fd21f109fbd2 100644
--- a/fs/jffs2/nodelist.c
+++ b/fs/jffs2/nodelist.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * For licensing information, see the file 'LICENCE' in this directory. 8 * For licensing information, see the file 'LICENCE' in this directory.
9 * 9 *
10 * $Id: nodelist.c,v 1.110 2005/08/17 14:13:45 dedekind Exp $ 10 * $Id: nodelist.c,v 1.111 2005/08/17 14:57:39 dedekind Exp $
11 * 11 *
12 */ 12 */
13 13
@@ -413,7 +413,8 @@ static int check_node_data(struct jffs2_sb_info *c, struct jffs2_tmp_dnode_info
413 /* Calculate how many bytes were already checked */ 413 /* Calculate how many bytes were already checked */
414 ofs = ref_offset(ref) + sizeof(struct jffs2_raw_inode); 414 ofs = ref_offset(ref) + sizeof(struct jffs2_raw_inode);
415 len = ofs & (c->wbuf_pagesize - 1); 415 len = ofs & (c->wbuf_pagesize - 1);
416 len = c->wbuf_pagesize - len; 416 if (likely(len))
417 len = c->wbuf_pagesize - len;
417 418
418 if (len >= tn->csize) { 419 if (len >= tn->csize) {
419 JFFS2_DBG_READINODE("no need to check node at %#08x, data length %u, data starts at %#08x - it has already been checked.\n", 420 JFFS2_DBG_READINODE("no need to check node at %#08x, data length %u, data starts at %#08x - it has already been checked.\n",
diff --git a/fs/jffs2/readinode.c b/fs/jffs2/readinode.c
index 6d5adaba4062..6f1e4a7ecd9f 100644
--- a/fs/jffs2/readinode.c
+++ b/fs/jffs2/readinode.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * For licensing information, see the file 'LICENCE' in this directory. 8 * For licensing information, see the file 'LICENCE' in this directory.
9 * 9 *
10 * $Id: readinode.c,v 1.140 2005/08/17 13:46:23 dedekind Exp $ 10 * $Id: readinode.c,v 1.141 2005/08/17 14:57:39 dedekind Exp $
11 * 11 *
12 */ 12 */
13 13
@@ -272,9 +272,9 @@ static inline int read_dnode(struct jffs2_sb_info *c, struct jffs2_raw_node_ref
272 buf = (unsigned char *)rd + sizeof(*rd); 272 buf = (unsigned char *)rd + sizeof(*rd);
273 /* len will be the read data length */ 273 /* len will be the read data length */
274 len = min_t(uint32_t, rdlen - sizeof(*rd), csize); 274 len = min_t(uint32_t, rdlen - sizeof(*rd), csize);
275 275 tn->partial_crc = crc32(0, buf, len);
276 if (len) 276
277 tn->partial_crc = crc = crc32(0, buf, len); 277 JFFS2_DBG_READINODE("Calculates CRC (%#08x) for %d bytes, csize %d\n", tn->partial_crc, len, csize);
278 278
279 /* If we actually calculated the whole data CRC 279 /* If we actually calculated the whole data CRC
280 * and it is wrong, drop the node. */ 280 * and it is wrong, drop the node. */
@@ -327,8 +327,8 @@ static inline int read_dnode(struct jffs2_sb_info *c, struct jffs2_raw_node_ref
327 else // normal case... 327 else // normal case...
328 tn->fn->size = je32_to_cpu(rd->dsize); 328 tn->fn->size = je32_to_cpu(rd->dsize);
329 329
330 JFFS2_DBG_READINODE("dnode @%08x: ver %u, offset %#04x, dsize %#04x\n", 330 JFFS2_DBG_READINODE("dnode @%08x: ver %u, offset %#04x, dsize %#04x, csize %#04x\n",
331 ref_offset(ref), je32_to_cpu(rd->version), je32_to_cpu(rd->offset), je32_to_cpu(rd->dsize)); 331 ref_offset(ref), je32_to_cpu(rd->version), je32_to_cpu(rd->offset), je32_to_cpu(rd->dsize), csize);
332 332
333 jffs2_add_tn_to_tree(tn, tnp); 333 jffs2_add_tn_to_tree(tn, tnp);
334 334