Skip to content

Commit c5020c5

Browse files
Sebastian Andrzej Siewiorgregkh
authored andcommitted
kernfs: Move dput() outside of the RCU section.
Al Viro pointed out that dput() might sleep and must not be invoked within an RCU section. Keep only find_next_ancestor() winthin the RCU section. Correct the wording in the comment. Fixes: 6ef5b6f ("kernfs: Drop kernfs_rwsem while invoking lookup_positive_unlocked().") Reported-by: Al Viro <[email protected]> Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent e965efc commit c5020c5

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

fs/kernfs/mount.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,17 +222,17 @@ struct dentry *kernfs_node_dentry(struct kernfs_node *kn,
222222
root = kernfs_root(kn);
223223
/*
224224
* As long as kn is valid, its parent can not vanish. This is cgroup's
225-
* kn so it not have its parent replaced. Therefore it is safe to use
225+
* kn so it can't have its parent replaced. Therefore it is safe to use
226226
* the ancestor node outside of the RCU or locked section.
227227
*/
228228
if (WARN_ON_ONCE(!(root->flags & KERNFS_ROOT_INVARIANT_PARENT)))
229229
return ERR_PTR(-EINVAL);
230230
scoped_guard(rcu) {
231231
knparent = find_next_ancestor(kn, NULL);
232-
if (WARN_ON(!knparent)) {
233-
dput(dentry);
234-
return ERR_PTR(-EINVAL);
235-
}
232+
}
233+
if (WARN_ON(!knparent)) {
234+
dput(dentry);
235+
return ERR_PTR(-EINVAL);
236236
}
237237

238238
do {

0 commit comments

Comments
 (0)