mtd/fs/jffs2 nodemgmt.c,1.78,1.79

David Woodhouse dwmw2 at infradead.org
Tue Sep 10 03:03:21 EDT 2002


Update of /home/cvs/mtd/fs/jffs2
In directory phoenix.infradead.org:/tmp/cvs-serv18153

Modified Files:
	nodemgmt.c 
Log Message:
Fix BUG() if used_size < ref->totlen which was triggering even if we weren't going to 
try subtracting that from there.


Index: nodemgmt.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/nodemgmt.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -r1.78 -r1.79
--- nodemgmt.c	9 Sep 2002 16:29:08 -0000	1.78
+++ nodemgmt.c	10 Sep 2002 07:03:18 -0000	1.79
@@ -354,20 +354,25 @@
 		BUG();
 	}
 	jeb = &c->blocks[blocknr];
-	if (jeb->used_size < ref->totlen) {
-		printk(KERN_NOTICE "raw node of size 0x%08x freed from erase block %d at 0x%08x, but used_size was already 0x%08x\n",
-		       ref->totlen, blocknr, ref->flash_offset, jeb->used_size);
-		BUG();
-	}
 
 	spin_lock_bh(&c->erase_completion_lock);
 
 	if (ref_flags(ref) == REF_UNCHECKED) {
 		D1(printk("Obsoleting previously unchecked node at 0x%08x of len %x: ", ref_offset(ref), ref->totlen));
+		if (jeb->unchecked_size < ref->totlen) {
+			printk(KERN_NOTICE "raw unchecked node of size 0x%08x freed from erase block %d at 0x%08x, but unchecked_size was already 0x%08x\n",
+			       ref->totlen, blocknr, ref->flash_offset, jeb->used_size);
+			BUG();
+		}
 		jeb->unchecked_size -= ref->totlen;
 		c->unchecked_size -= ref->totlen;
 	} else {
 		D1(printk("Obsoleting node at 0x%08x of len %x: ", ref_offset(ref), ref->totlen));
+		if (jeb->used_size < ref->totlen) {
+			printk(KERN_NOTICE "raw node of size 0x%08x freed from erase block %d at 0x%08x, but used_size was already 0x%08x\n",
+			       ref->totlen, blocknr, ref->flash_offset, jeb->used_size);
+			BUG();
+		}
 		jeb->used_size -= ref->totlen;
 		c->used_size -= ref->totlen;
 	}





More information about the linux-mtd-cvs mailing list