Skip to content

Commit

Permalink
autofs4 - fix get_next_positive_dentry()
Browse files Browse the repository at this point in the history
The initialization condition in fs/autofs4/expire.c:get_next_positive_dentry()
appears to be incorrect. If prev == NULL I believe that root should be
returned.

Further down, at the current dentry check for it being simple_positive()
it looks like the d_lock for dentry p should be dropped instead of dentry
ret, otherwise when p is assinged to ret we end up with no lock on p and
a lost lock on ret, which leads to a deadlock.

Signed-off-by: Ian Kent <raven@themaw.net>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Ian Kent authored and Al Viro committed Jan 18, 2011
1 parent 6845a44 commit c14cc63
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fs/autofs4/expire.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static struct dentry *get_next_positive_dentry(struct dentry *prev,
struct dentry *p, *ret;

if (prev == NULL)
return dget(prev);
return dget(root);

spin_lock(&autofs4_lock);
relock:
Expand Down Expand Up @@ -133,7 +133,7 @@ static struct dentry *get_next_positive_dentry(struct dentry *prev,
spin_lock_nested(&ret->d_lock, DENTRY_D_LOCK_NESTED);
/* Negative dentry - try next */
if (!simple_positive(ret)) {
spin_unlock(&ret->d_lock);
spin_unlock(&p->d_lock);
p = ret;
goto again;
}
Expand Down

0 comments on commit c14cc63

Please sign in to comment.