Skip to content

Commit 0307d16

Browse files
dhowellsbrauner
authored andcommitted
afs: Fix afs_atcell_get_link() to check if ws_cell is unset first
Fix afs_atcell_get_link() to check if the workstation cell is unset before doing the RCU pathwalk bit where we dereference that. Fixes: 823869e ("afs: Fix afs_atcell_get_link() to handle RCU pathwalk") Reported-by: [email protected] Signed-off-by: David Howells <[email protected]> Link: https://lore.kernel.org/r/[email protected] Tested-by: [email protected] cc: Marc Dionne <[email protected]> cc: [email protected] cc: [email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent 4701f33 commit 0307d16

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fs/afs/dynroot.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,9 @@ static const char *afs_atcell_get_link(struct dentry *dentry, struct inode *inod
314314
const char *name;
315315
bool dotted = vnode->fid.vnode == 3;
316316

317+
if (!rcu_access_pointer(net->ws_cell))
318+
return ERR_PTR(-ENOENT);
319+
317320
if (!dentry) {
318321
/* We're in RCU-pathwalk. */
319322
cell = rcu_dereference(net->ws_cell);
@@ -325,9 +328,6 @@ static const char *afs_atcell_get_link(struct dentry *dentry, struct inode *inod
325328
return name;
326329
}
327330

328-
if (!rcu_access_pointer(net->ws_cell))
329-
return ERR_PTR(-ENOENT);
330-
331331
down_read(&net->cells_lock);
332332

333333
cell = rcu_dereference_protected(net->ws_cell, lockdep_is_held(&net->cells_lock));

0 commit comments

Comments
 (0)