NFS: handle inode==NULL in __put_nfs_open_context
authorBenny Halevy <bhalevy@panasas.com>
Thu, 23 Sep 2010 16:22:09 +0000 (12:22 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Thu, 23 Sep 2010 16:22:09 +0000 (12:22 -0400)
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>
fs/nfs/inode.c

index 2ff814272dcfc343066f99c6d83c04ad7c3360d7..702ed096e790dc737663c47a2ff27121b8272eb0 100644 (file)
@@ -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);