mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-03 23:58:05 +00:00
proc: avoid extra pde_put() in proc_fill_super()
If proc_get_inode() succeeded, but d_make_root() failed, pde_put() for proc_root will be called twice: the first time due to iput() called from d_make_root() and the second time directly in the end of proc_fill_super(). Signed-off-by: Maxim Patlasov <mpatlasov@parallels.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
4173581876
commit
87e0aab37f
1 changed files with 15 additions and 6 deletions
|
@ -486,6 +486,8 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
|
||||||
|
|
||||||
int proc_fill_super(struct super_block *s)
|
int proc_fill_super(struct super_block *s)
|
||||||
{
|
{
|
||||||
|
struct inode *root_inode;
|
||||||
|
|
||||||
s->s_flags |= MS_NODIRATIME | MS_NOSUID | MS_NOEXEC;
|
s->s_flags |= MS_NODIRATIME | MS_NOSUID | MS_NOEXEC;
|
||||||
s->s_blocksize = 1024;
|
s->s_blocksize = 1024;
|
||||||
s->s_blocksize_bits = 10;
|
s->s_blocksize_bits = 10;
|
||||||
|
@ -494,11 +496,18 @@ int proc_fill_super(struct super_block *s)
|
||||||
s->s_time_gran = 1;
|
s->s_time_gran = 1;
|
||||||
|
|
||||||
pde_get(&proc_root);
|
pde_get(&proc_root);
|
||||||
s->s_root = d_make_root(proc_get_inode(s, &proc_root));
|
root_inode = proc_get_inode(s, &proc_root);
|
||||||
if (s->s_root)
|
if (!root_inode) {
|
||||||
return 0;
|
printk(KERN_ERR "proc_fill_super: get root inode failed\n");
|
||||||
|
pde_put(&proc_root);
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
printk("proc_read_super: get root inode failed\n");
|
s->s_root = d_make_root(root_inode);
|
||||||
pde_put(&proc_root);
|
if (!s->s_root) {
|
||||||
return -ENOMEM;
|
printk(KERN_ERR "proc_fill_super: allocate dentry failed\n");
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue