Commit e9543659 authored by Kirill Korotaev's avatar Kirill Korotaev Committed by Linus Torvalds

[PATCH] proc: fix of error path in proc_get_inode()

This patch fixes incorrect error path in proc_get_inode(), when module
can't be get due to being unloaded.  When try_module_get() fails, this
function puts de(!) and still returns inode with non-getted de.

There are still unresolved known bugs in proc yet to be fixed:
- proc_dir_entry tree is managed without any serialization
- create_proc_entry() doesn't setup de->owner anyhow,
   so setting it later manually is inatomic.
- looks like almost all modules do not care whether
   it's de->owner is set...
Signed-Off-By: default avatarDenis Lunev <den@sw.ru>
Signed-Off-By: default avatarKirill Korotaev <dev@sw.ru>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent f12ec440
...@@ -156,9 +156,12 @@ struct inode *proc_get_inode(struct super_block *sb, unsigned int ino, ...@@ -156,9 +156,12 @@ struct inode *proc_get_inode(struct super_block *sb, unsigned int ino,
WARN_ON(de && de->deleted); WARN_ON(de && de->deleted);
if (de != NULL && !try_module_get(de->owner))
goto out_mod;
inode = iget(sb, ino); inode = iget(sb, ino);
if (!inode) if (!inode)
goto out_fail; goto out_ino;
PROC_I(inode)->pde = de; PROC_I(inode)->pde = de;
if (de) { if (de) {
...@@ -171,20 +174,20 @@ struct inode *proc_get_inode(struct super_block *sb, unsigned int ino, ...@@ -171,20 +174,20 @@ struct inode *proc_get_inode(struct super_block *sb, unsigned int ino,
inode->i_size = de->size; inode->i_size = de->size;
if (de->nlink) if (de->nlink)
inode->i_nlink = de->nlink; inode->i_nlink = de->nlink;
if (!try_module_get(de->owner))
goto out_fail;
if (de->proc_iops) if (de->proc_iops)
inode->i_op = de->proc_iops; inode->i_op = de->proc_iops;
if (de->proc_fops) if (de->proc_fops)
inode->i_fop = de->proc_fops; inode->i_fop = de->proc_fops;
} }
out:
return inode; return inode;
out_fail: out_ino:
if (de != NULL)
module_put(de->owner);
out_mod:
de_put(de); de_put(de);
goto out; return NULL;
} }
int proc_fill_super(struct super_block *s, void *data, int silent) int proc_fill_super(struct super_block *s, void *data, int silent)
......
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