nfs41: fix nfs4_proc_layoutget error handling
authorPeng Tao <tao.peng@primarydata.com>
Mon, 17 Nov 2014 03:05:17 +0000 (11:05 +0800)
committerTrond Myklebust <trond.myklebust@primarydata.com>
Mon, 24 Nov 2014 22:14:54 +0000 (17:14 -0500)
nfs4_layoutget_release() drops layout hdr refcnt. Grab the refcnt
early so that it is safe to call .release in case nfs4_alloc_pages
fails.

Signed-off-by: Peng Tao <tao.peng@primarydata.com>
Fixes: a47970ff78147 ("NFSv4.1: Hold reference to layout hdr in layoutget")
Cc: stable@vger.kernel.org # 3.9+
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
fs/nfs/nfs4proc.c

index 15d5eb52cde8f23efa70afc53a3b6d361bd57a2c..3138913d1cdf1a92cf37d0ca13f4cd60ea4db940 100644 (file)
@@ -7702,6 +7702,9 @@ nfs4_proc_layoutget(struct nfs4_layoutget *lgp, gfp_t gfp_flags)
 
        dprintk("--> %s\n", __func__);
 
+       /* nfs4_layoutget_release calls pnfs_put_layout_hdr */
+       pnfs_get_layout_hdr(NFS_I(inode)->layout);
+
        lgp->args.layout.pages = nfs4_alloc_pages(max_pages, gfp_flags);
        if (!lgp->args.layout.pages) {
                nfs4_layoutget_release(lgp);
@@ -7714,9 +7717,6 @@ nfs4_proc_layoutget(struct nfs4_layoutget *lgp, gfp_t gfp_flags)
        lgp->res.seq_res.sr_slot = NULL;
        nfs4_init_sequence(&lgp->args.seq_args, &lgp->res.seq_res, 0);
 
-       /* nfs4_layoutget_release calls pnfs_put_layout_hdr */
-       pnfs_get_layout_hdr(NFS_I(inode)->layout);
-
        task = rpc_run_task(&task_setup_data);
        if (IS_ERR(task))
                return ERR_CAST(task);