Skip to content

Commit fa59f52

Browse files
committed
afs: afs_unlink() doesn't need to check dentry->d_inode
Don't check that dentry->d_inode is valid in afs_unlink(). We should be able to take that as given. This caused Smatch to issue the following warning: fs/afs/dir.c:1392 afs_unlink() error: we previously assumed 'vnode' could be null (see line 1375) Reported-by: kbuild test robot <[email protected]> Reported-by: Dan Carpenter <[email protected]> Signed-off-by: David Howells <[email protected]>
1 parent 2cd42d1 commit fa59f52

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

fs/afs/dir.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,7 +1394,8 @@ static int afs_unlink(struct inode *dir, struct dentry *dentry)
13941394
{
13951395
struct afs_fs_cursor fc;
13961396
struct afs_status_cb *scb;
1397-
struct afs_vnode *dvnode = AFS_FS_I(dir), *vnode = NULL;
1397+
struct afs_vnode *dvnode = AFS_FS_I(dir);
1398+
struct afs_vnode *vnode = AFS_FS_I(d_inode(dentry));
13981399
struct key *key;
13991400
bool need_rehash = false;
14001401
int ret;
@@ -1417,15 +1418,12 @@ static int afs_unlink(struct inode *dir, struct dentry *dentry)
14171418
}
14181419

14191420
/* Try to make sure we have a callback promise on the victim. */
1420-
if (d_really_is_positive(dentry)) {
1421-
vnode = AFS_FS_I(d_inode(dentry));
1422-
ret = afs_validate(vnode, key);
1423-
if (ret < 0)
1424-
goto error_key;
1425-
}
1421+
ret = afs_validate(vnode, key);
1422+
if (ret < 0)
1423+
goto error_key;
14261424

14271425
spin_lock(&dentry->d_lock);
1428-
if (vnode && d_count(dentry) > 1) {
1426+
if (d_count(dentry) > 1) {
14291427
spin_unlock(&dentry->d_lock);
14301428
/* Start asynchronous writeout of the inode */
14311429
write_inode_now(d_inode(dentry), 0);

0 commit comments

Comments
 (0)