mtd/fs/jffs2 gc.c,1.100,1.101 readinode.c,1.103,1.104

David Woodhouse dwmw2 at infradead.org
Tue Mar 11 12:19:59 EST 2003


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

Modified Files:
	gc.c readinode.c 
Log Message:
Fix memory leak of inodes read for crc32 check.


Index: gc.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/gc.c,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -r1.100 -r1.101
--- gc.c	22 Jan 2003 14:43:51 -0000	1.100
+++ gc.c	11 Mar 2003 17:19:56 -0000	1.101
@@ -191,8 +191,10 @@
 		D1(printk(KERN_DEBUG "jffs2_garbage_collect_pass() triggering inode scan of ino#%d\n", ic->ino));
 
 		ret = jffs2_do_crccheck_inode(c, ic);
-		if (!ret)
-			jffs2_set_inocache_state(c, ic, INO_STATE_CHECKEDABSENT);
+		if (ret)
+			printk(KERN_WARNING "Returned error for crccheck of ino #%u. Expect badness...\n", ic->ino);
+
+		jffs2_set_inocache_state(c, ic, INO_STATE_CHECKEDABSENT);
 		up(&c->alloc_sem);
 		return ret;
 	}

Index: readinode.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/readinode.c,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -r1.103 -r1.104
--- readinode.c	22 Jan 2003 14:43:29 -0000	1.103
+++ readinode.c	11 Mar 2003 17:19:56 -0000	1.104
@@ -408,6 +408,7 @@
 {
 	struct jffs2_raw_inode n;
 	struct jffs2_inode_info *f = kmalloc(sizeof(*f), GFP_KERNEL);
+	int ret;
 
 	if (!f)
 		return -ENOMEM;
@@ -416,7 +417,12 @@
 	init_MUTEX_LOCKED(&f->sem);
 	f->inocache = ic;
 
-	return jffs2_do_read_inode_internal(c, f, &n);
+	ret = jffs2_do_read_inode_internal(c, f, &n);
+	if (!ret) {
+		up(&f->sem);
+		jffs2_do_clear_inode(c, f);
+	}
+	return ret;
 }
 
 static int jffs2_do_read_inode_internal(struct jffs2_sb_info *c, 
@@ -450,13 +456,21 @@
 
 		fn = tn->fn;
 
-		if (f->metadata && tn->version > mdata_ver) {
-			D1(printk(KERN_DEBUG "Obsoleting old metadata at 0x%08x\n", ref_offset(f->metadata->raw)));
-			jffs2_mark_node_obsolete(c, f->metadata->raw);
-			jffs2_free_full_dnode(f->metadata);
-			f->metadata = NULL;
-			
-			mdata_ver = 0;
+		if (f->metadata) {
+			if (tn->version > mdata_ver) {
+				D1(printk(KERN_DEBUG "Obsoleting old metadata at 0x%08x\n", ref_offset(f->metadata->raw)));
+				jffs2_mark_node_obsolete(c, f->metadata->raw);
+				jffs2_free_full_dnode(f->metadata);
+				f->metadata = NULL;
+				
+				mdata_ver = 0;
+			} else {
+				D1(printk(KERN_DEBUG "Er. New metadata at 0x%08x with ver %d is actually older than previous %d\n",
+				       ref_offset(f->metadata->raw), tn->version, mdata_ver));
+				jffs2_mark_node_obsolete(c, fn->raw);
+				jffs2_free_full_dnode(fn);
+				goto next_tn;
+			}
 		}
 
 		if (fn->size) {
@@ -467,6 +481,7 @@
 			f->metadata = fn;
 			mdata_ver = tn->version;
 		}
+	next_tn:
 		tn_list = tn->next;
 		jffs2_free_tmp_dnode_info(tn);
 	}





More information about the linux-mtd-cvs mailing list