Skip to content

Commit

Permalink
Don't mess with generic_permission() under ->d_lock in hpfs
Browse files Browse the repository at this point in the history
Just use dentry_unhash() there

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Mar 3, 2010
1 parent 391e8bb commit e21e709
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions fs/hpfs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,22 +413,25 @@ static int hpfs_unlink(struct inode *dir, struct dentry *dentry)

mutex_unlock(&hpfs_i(dir)->i_mutex);
mutex_unlock(&hpfs_i(inode)->i_parent_mutex);
d_drop(dentry);
spin_lock(&dentry->d_lock);
if (atomic_read(&dentry->d_count) > 1 ||
generic_permission(inode, MAY_WRITE, NULL) ||
dentry_unhash(dentry);
if (!d_unhashed(dentry)) {
dput(dentry);
unlock_kernel();
return -ENOSPC;
}
if (generic_permission(inode, MAY_WRITE, NULL) ||
!S_ISREG(inode->i_mode) ||
get_write_access(inode)) {
spin_unlock(&dentry->d_lock);
d_rehash(dentry);
dput(dentry);
} else {
struct iattr newattrs;
spin_unlock(&dentry->d_lock);
/*printk("HPFS: truncating file before delete.\n");*/
newattrs.ia_size = 0;
newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
err = notify_change(dentry, &newattrs);
put_write_access(inode);
dput(dentry);
if (!err)
goto again;
}
Expand Down

0 comments on commit e21e709

Please sign in to comment.