Skip to content

Commit

Permalink
afs: afs_unlink() doesn't need to check dentry->d_inode
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
dhowells committed Jun 20, 2019
1 parent 2cd42d1 commit fa59f52
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions fs/afs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1394,7 +1394,8 @@ static int afs_unlink(struct inode *dir, struct dentry *dentry)
{
struct afs_fs_cursor fc;
struct afs_status_cb *scb;
struct afs_vnode *dvnode = AFS_FS_I(dir), *vnode = NULL;
struct afs_vnode *dvnode = AFS_FS_I(dir);
struct afs_vnode *vnode = AFS_FS_I(d_inode(dentry));
struct key *key;
bool need_rehash = false;
int ret;
Expand All @@ -1417,15 +1418,12 @@ static int afs_unlink(struct inode *dir, struct dentry *dentry)
}

/* Try to make sure we have a callback promise on the victim. */
if (d_really_is_positive(dentry)) {
vnode = AFS_FS_I(d_inode(dentry));
ret = afs_validate(vnode, key);
if (ret < 0)
goto error_key;
}
ret = afs_validate(vnode, key);
if (ret < 0)
goto error_key;

spin_lock(&dentry->d_lock);
if (vnode && d_count(dentry) > 1) {
if (d_count(dentry) > 1) {
spin_unlock(&dentry->d_lock);
/* Start asynchronous writeout of the inode */
write_inode_now(d_inode(dentry), 0);
Expand Down

0 comments on commit fa59f52

Please sign in to comment.