aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc
diff options
context:
space:
mode:
authorMaxim Patlasov <mpatlasov@parallels.com>2013-02-19 21:13:32 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2013-02-26 02:46:14 -0500
commit87e0aab37ff6c4284810a48d6034314fbf4eb319 (patch)
tree8e60b24d094edef3d5b6d347444fe4db8c688f10 /fs/proc
parent41735818766c0ec215b9a69591e7eae642061954 (diff)
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>
Diffstat (limited to 'fs/proc')
-rw-r--r--fs/proc/inode.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index 38f5c119b806..98a7d2870bef 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -486,6 +486,8 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
486 486
487int proc_fill_super(struct super_block *s) 487int proc_fill_super(struct super_block *s)
488{ 488{
489 struct inode *root_inode;
490
489 s->s_flags |= MS_NODIRATIME | MS_NOSUID | MS_NOEXEC; 491 s->s_flags |= MS_NODIRATIME | MS_NOSUID | MS_NOEXEC;
490 s->s_blocksize = 1024; 492 s->s_blocksize = 1024;
491 s->s_blocksize_bits = 10; 493 s->s_blocksize_bits = 10;
@@ -494,11 +496,18 @@ int proc_fill_super(struct super_block *s)
494 s->s_time_gran = 1; 496 s->s_time_gran = 1;
495 497
496 pde_get(&proc_root); 498 pde_get(&proc_root);
497 s->s_root = d_make_root(proc_get_inode(s, &proc_root)); 499 root_inode = proc_get_inode(s, &proc_root);
498 if (s->s_root) 500 if (!root_inode) {
499 return 0; 501 printk(KERN_ERR "proc_fill_super: get root inode failed\n");
502 pde_put(&proc_root);
503 return -ENOMEM;
504 }
500 505
501 printk("proc_read_super: get root inode failed\n"); 506 s->s_root = d_make_root(root_inode);
502 pde_put(&proc_root); 507 if (!s->s_root) {
503 return -ENOMEM; 508 printk(KERN_ERR "proc_fill_super: allocate dentry failed\n");
509 return -ENOMEM;
510 }
511
512 return 0;
504} 513}