nfsd: don't run get_file if nfs4_preprocess_stateid_op return error
authorfanchaoting <fanchaoting@cn.fujitsu.com>
Mon, 1 Apr 2013 13:07:22 +0000 (21:07 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 7 Jun 2014 23:02:05 +0000 (16:02 -0700)
commit b022032e195ffca83d7002d6b84297d796ed443b upstream.

we should return error status directly when nfs4_preprocess_stateid_op
return error.

Signed-off-by: fanchaoting <fanchaoting@cn.fujitsu.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Cc: Rui Xiang <rui.xiang@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/nfsd/nfs4proc.c

index e540494..97a142c 100644 (file)
@@ -904,14 +904,14 @@ nfsd4_write(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 
        nfs4_lock_state();
        status = nfs4_preprocess_stateid_op(cstate, stateid, WR_STATE, &filp);
-       if (filp)
-               get_file(filp);
-       nfs4_unlock_state();
-
        if (status) {
+               nfs4_unlock_state();
                dprintk("NFSD: nfsd4_write: couldn't process stateid!\n");
                return status;
        }
+       if (filp)
+               get_file(filp);
+       nfs4_unlock_state();
 
        cnt = write->wr_buflen;
        write->wr_how_written = write->wr_stable_how;