Skip to content

Commit

Permalink
NFS: handle inode==NULL in __put_nfs_open_context
Browse files Browse the repository at this point in the history
inode may be NULL when put_nfs_open_context is called from nfs_atomic_lookup
before d_add_unique(dentry, inode)

Signed-off-by: Benny Halevy <bhalevy@panasas.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
  • Loading branch information
Benny Halevy authored and Trond Myklebust committed Sep 23, 2010
1 parent 5eebde2 commit ef84303
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions fs/nfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,11 +654,14 @@ static void __put_nfs_open_context(struct nfs_open_context *ctx, int is_sync)
{
struct inode *inode = ctx->path.dentry->d_inode;

if (!atomic_dec_and_lock(&ctx->lock_context.count, &inode->i_lock))
if (inode) {
if (!atomic_dec_and_lock(&ctx->lock_context.count, &inode->i_lock))
return;
list_del(&ctx->list);
spin_unlock(&inode->i_lock);
NFS_PROTO(inode)->close_context(ctx, is_sync);
} else if (!atomic_dec_and_test(&ctx->lock_context.count))
return;
list_del(&ctx->list);
spin_unlock(&inode->i_lock);
NFS_PROTO(inode)->close_context(ctx, is_sync);
if (ctx->cred != NULL)
put_rpccred(ctx->cred);
path_put(&ctx->path);
Expand Down

0 comments on commit ef84303

Please sign in to comment.