Skip to content

Commit 30da870

Browse files
author
Al Viro
committed
affs_lookup(): close a race with affs_remove_link()
we unlock the directory hash too early - if we are looking at secondary link and primary (in another directory) gets removed just as we unlock, we could have the old primary moved in place of the secondary, leaving us to look into freed entry (and leaving our dentry with ->d_fsdata pointing to a freed entry). Cc: [email protected] # 2.4.4+ Acked-by: David Sterba <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent b127125 commit 30da870

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

fs/affs/namei.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,10 @@ affs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
206206

207207
affs_lock_dir(dir);
208208
bh = affs_find_entry(dir, dentry);
209-
affs_unlock_dir(dir);
210-
if (IS_ERR(bh))
209+
if (IS_ERR(bh)) {
210+
affs_unlock_dir(dir);
211211
return ERR_CAST(bh);
212+
}
212213
if (bh) {
213214
u32 ino = bh->b_blocknr;
214215

@@ -222,10 +223,13 @@ affs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
222223
}
223224
affs_brelse(bh);
224225
inode = affs_iget(sb, ino);
225-
if (IS_ERR(inode))
226+
if (IS_ERR(inode)) {
227+
affs_unlock_dir(dir);
226228
return ERR_CAST(inode);
229+
}
227230
}
228231
d_add(dentry, inode);
232+
affs_unlock_dir(dir);
229233
return NULL;
230234
}
231235

0 commit comments

Comments
 (0)