diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2018-05-03 09:45:06 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2018-05-26 14:20:50 -0400 |
commit | 888e2b03ef56694290e58bd9ac23f8033bf6369f (patch) | |
tree | 71b2bfef0e1a8c09b47ceac8d1f94411499e5c94 | |
parent | 0168b9e38c4213e162b15444c071d4198ff470e8 (diff) |
switch the rest of procfs lookups to d_splice_alias()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/proc/generic.c | 3 | ||||
-rw-r--r-- | fs/proc/proc_sysctl.c | 15 |
2 files changed, 13 insertions, 5 deletions
diff --git a/fs/proc/generic.c b/fs/proc/generic.c index 2078e70e1595..b77034a694ef 100644 --- a/fs/proc/generic.c +++ b/fs/proc/generic.c | |||
@@ -256,8 +256,7 @@ struct dentry *proc_lookup_de(struct inode *dir, struct dentry *dentry, | |||
256 | if (!inode) | 256 | if (!inode) |
257 | return ERR_PTR(-ENOMEM); | 257 | return ERR_PTR(-ENOMEM); |
258 | d_set_d_op(dentry, &proc_misc_dentry_ops); | 258 | d_set_d_op(dentry, &proc_misc_dentry_ops); |
259 | d_add(dentry, inode); | 259 | return d_splice_alias(inode, dentry); |
260 | return NULL; | ||
261 | } | 260 | } |
262 | read_unlock(&proc_subdir_lock); | 261 | read_unlock(&proc_subdir_lock); |
263 | return ERR_PTR(-ENOENT); | 262 | return ERR_PTR(-ENOENT); |
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 8989936f2995..4d765e5e91ed 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c | |||
@@ -554,9 +554,8 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry, | |||
554 | if (!inode) | 554 | if (!inode) |
555 | goto out; | 555 | goto out; |
556 | 556 | ||
557 | err = NULL; | ||
558 | d_set_d_op(dentry, &proc_sys_dentry_operations); | 557 | d_set_d_op(dentry, &proc_sys_dentry_operations); |
559 | d_add(dentry, inode); | 558 | err = d_splice_alias(inode, dentry); |
560 | 559 | ||
561 | out: | 560 | out: |
562 | if (h) | 561 | if (h) |
@@ -684,6 +683,7 @@ static bool proc_sys_fill_cache(struct file *file, | |||
684 | if (IS_ERR(child)) | 683 | if (IS_ERR(child)) |
685 | return false; | 684 | return false; |
686 | if (d_in_lookup(child)) { | 685 | if (d_in_lookup(child)) { |
686 | struct dentry *res; | ||
687 | inode = proc_sys_make_inode(dir->d_sb, head, table); | 687 | inode = proc_sys_make_inode(dir->d_sb, head, table); |
688 | if (!inode) { | 688 | if (!inode) { |
689 | d_lookup_done(child); | 689 | d_lookup_done(child); |
@@ -691,7 +691,16 @@ static bool proc_sys_fill_cache(struct file *file, | |||
691 | return false; | 691 | return false; |
692 | } | 692 | } |
693 | d_set_d_op(child, &proc_sys_dentry_operations); | 693 | d_set_d_op(child, &proc_sys_dentry_operations); |
694 | d_add(child, inode); | 694 | res = d_splice_alias(inode, child); |
695 | d_lookup_done(child); | ||
696 | if (unlikely(res)) { | ||
697 | if (IS_ERR(res)) { | ||
698 | dput(child); | ||
699 | return false; | ||
700 | } | ||
701 | dput(child); | ||
702 | child = res; | ||
703 | } | ||
695 | } | 704 | } |
696 | } | 705 | } |
697 | inode = d_inode(child); | 706 | inode = d_inode(child); |