Commit 355ed4e1 authored by KaiGai Kohei's avatar KaiGai Kohei Committed by David Woodhouse

[JFFS2][XATTR] Fix memory leak with jffs2_xattr_ref

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: default avatarKaiGai Kohei <kaigai@ak.jp.nec.com>
Signed-off-by: default avatarDavid Woodhouse <dwmw2@infradead.org>
parent 8a13695c
...@@ -227,8 +227,6 @@ void jffs2_clear_inode (struct inode *inode) ...@@ -227,8 +227,6 @@ void jffs2_clear_inode (struct inode *inode)
struct jffs2_inode_info *f = JFFS2_INODE_INFO(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)); 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); jffs2_do_clear_inode(c, f);
} }
......
...@@ -165,6 +165,7 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c) ...@@ -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", D1(printk(KERN_DEBUG "Skipping check of ino #%d with nlink zero\n",
ic->ino)); ic->ino));
spin_unlock(&c->inocache_lock); spin_unlock(&c->inocache_lock);
jffs2_xattr_delete_inode(c, ic);
continue; continue;
} }
switch(ic->state) { switch(ic->state) {
......
...@@ -906,6 +906,9 @@ void jffs2_del_ino_cache(struct jffs2_sb_info *c, struct jffs2_inode_cache *old) ...@@ -906,6 +906,9 @@ void jffs2_del_ino_cache(struct jffs2_sb_info *c, struct jffs2_inode_cache *old)
{ {
struct jffs2_inode_cache **prev; 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); dbg_inocache("del %p (ino #%u)\n", old, old->ino);
spin_lock(&c->inocache_lock); spin_lock(&c->inocache_lock);
......
...@@ -968,6 +968,7 @@ void jffs2_do_clear_inode(struct jffs2_sb_info *c, struct jffs2_inode_info *f) ...@@ -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; struct jffs2_full_dirent *fd, *fds;
int deleted; int deleted;
jffs2_xattr_delete_inode(c, f->inocache);
down(&f->sem); down(&f->sem);
deleted = f->inocache && !f->inocache->nlink; deleted = f->inocache && !f->inocache->nlink;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment