[JFFS2][XATTR] Fix memory leak with jffs2_xattr_ref
authorKaiGai Kohei <kaigai@ak.jp.nec.com>
Sat, 24 Jun 2006 00:15:36 +0000 (09:15 +0900)
committerDavid Woodhouse <dwmw2@infradead.org>
Tue, 27 Jun 2006 15:18:30 +0000 (16:18 +0100)
If xattr_ref is associated with an orphan inode_cache
on filesystem mounting, those xattr_refs are not
released even if this inode_cache is released.

This patch enables to call jffs2_xattr_delete_inode()
for such a irregular inode_cachde too.

Signed-off-by: KaiGai Kohei <kaigai@ak.jp.nec.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
fs/jffs2/fs.c
fs/jffs2/gc.c
fs/jffs2/nodelist.c
fs/jffs2/readinode.c

index 2900ec3ec3afb79614a5479179880d0682dddf20..97caa77d60cf23db5ce8dc98848780e2a1caf49c 100644 (file)
@@ -227,8 +227,6 @@ void jffs2_clear_inode (struct inode *inode)
        struct jffs2_inode_info *f = JFFS2_INODE_INFO(inode);
 
        D1(printk(KERN_DEBUG "jffs2_clear_inode(): ino #%lu mode %o\n", inode->i_ino, inode->i_mode));
-
-       jffs2_xattr_delete_inode(c, f->inocache);
        jffs2_do_clear_inode(c, f);
 }
 
index f59b147661c9ac45b0249e4ba0f5dcf69508658a..daff3341ff92b58cb72916678f69603e64ed5972 100644 (file)
@@ -165,6 +165,7 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c)
                        D1(printk(KERN_DEBUG "Skipping check of ino #%d with nlink zero\n",
                                  ic->ino));
                        spin_unlock(&c->inocache_lock);
+                       jffs2_xattr_delete_inode(c, ic);
                        continue;
                }
                switch(ic->state) {
index 927dfe42ba76cab92b6fae6a39c09baa71d7f607..7675b33396c7d7c307c803d0a3db57c95e8371a7 100644 (file)
@@ -906,6 +906,9 @@ void jffs2_del_ino_cache(struct jffs2_sb_info *c, struct jffs2_inode_cache *old)
 {
        struct jffs2_inode_cache **prev;
 
+#ifdef CONFIG_JFFS2_FS_XATTR
+       BUG_ON(old->xref);
+#endif
        dbg_inocache("del %p (ino #%u)\n", old, old->ino);
        spin_lock(&c->inocache_lock);
 
index 5fec012b02ed59a1fa5f8ca871849af4c24e4e40..cc1899268c439a0c68e8bc877c6f4c56854bd3ba 100644 (file)
@@ -968,6 +968,7 @@ void jffs2_do_clear_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f)
        struct jffs2_full_dirent *fd, *fds;
        int deleted;
 
+       jffs2_xattr_delete_inode(c, f->inocache);
        down(&f->sem);
        deleted = f->inocache && !f->inocache->nlink;