]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
NFSv4.1: Fix a reference leak in pnfs_update_layout
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Fri, 21 Sep 2012 01:25:19 +0000 (21:25 -0400)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Fri, 21 Sep 2012 01:31:01 +0000 (21:31 -0400)
If we exit after the call to pnfs_find_alloc_layout(), we have to ensure
that we put the struct pnfs_layout_hdr.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
fs/nfs/pnfs.c

index 6656cb41afffc318a9e37a7c6b44e811f413566b..cbbb0fcd125ac2c35cc223fc96ce82c888dd9829 100644 (file)
@@ -1070,7 +1070,8 @@ pnfs_update_layout(struct inode *ino,
        lo = pnfs_find_alloc_layout(ino, ctx, gfp_flags);
        if (lo == NULL) {
                dprintk("%s ERROR: can't get pnfs_layout_hdr\n", __func__);
-               goto out_unlock;
+               spin_unlock(&ino->i_lock);
+               return NULL;
        }
 
        /* Do we even need to bother with this? */
@@ -1125,8 +1126,8 @@ pnfs_update_layout(struct inode *ino,
                spin_unlock(&clp->cl_lock);
        }
        atomic_dec(&lo->plh_outstanding);
-       pnfs_put_layout_hdr(lo);
 out:
+       pnfs_put_layout_hdr(lo);
        dprintk("%s end, state 0x%lx lseg %p\n", __func__,
                nfsi->layout ? nfsi->layout->plh_flags : -1, lseg);
        return lseg;