NFS: Fix an Oops in encode_lookup()
[safe/jmp/linux-2.6] / fs / nfs / nfs4xdr.c
index 5eb92f1..badd73b 100644 (file)
@@ -1168,12 +1168,10 @@ static int encode_read(struct xdr_stream *xdr, const struct nfs_readargs *args)
 
 static int encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_arg *readdir, struct rpc_rqst *req)
 {
-       struct rpc_auth *auth = req->rq_task->tk_msg.rpc_cred->cr_auth;
        uint32_t attrs[2] = {
                FATTR4_WORD0_RDATTR_ERROR|FATTR4_WORD0_FILEID,
                FATTR4_WORD1_MOUNTED_ON_FILEID,
        };
-       int replen;
        __be32 *p;
 
        RESERVE_SPACE(12+NFS4_VERIFIER_SIZE+20);
@@ -1198,37 +1196,16 @@ static int encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_arg
                        attrs[0] & readdir->bitmask[0],
                        attrs[1] & readdir->bitmask[1]);
 
-       /* set up reply kvec
-        *    toplevel_status + taglen + rescount + OP_PUTFH + status
-        *      + OP_READDIR + status + verifer(2)  = 9
-        */
-       replen = (RPC_REPHDRSIZE + auth->au_rslack + 9) << 2;
-       xdr_inline_pages(&req->rq_rcv_buf, replen, readdir->pages,
-                        readdir->pgbase, readdir->count);
-       dprintk("%s: inlined page args = (%u, %p, %u, %u)\n",
-                       __FUNCTION__, replen, readdir->pages,
-                       readdir->pgbase, readdir->count);
-
        return 0;
 }
 
 static int encode_readlink(struct xdr_stream *xdr, const struct nfs4_readlink *readlink, struct rpc_rqst *req)
 {
-       struct rpc_auth *auth = req->rq_task->tk_msg.rpc_cred->cr_auth;
-       unsigned int replen;
        __be32 *p;
 
        RESERVE_SPACE(4);
        WRITE32(OP_READLINK);
 
-       /* set up reply kvec
-        *    toplevel_status + taglen + rescount + OP_PUTFH + status
-        *      + OP_READLINK + status + string length = 8
-        */
-       replen = (RPC_REPHDRSIZE + auth->au_rslack + 8) << 2;
-       xdr_inline_pages(&req->rq_rcv_buf, replen, readlink->pages,
-                       readlink->pgbase, readlink->pglen);
-       
        return 0;
 }
 
@@ -1458,7 +1435,7 @@ out:
 /*
  * Encode REMOVE request
  */
-static int nfs4_xdr_enc_remove(struct rpc_rqst *req, __be32 *p, const struct nfs4_remove_arg *args)
+static int nfs4_xdr_enc_remove(struct rpc_rqst *req, __be32 *p, const struct nfs_removeargs *args)
 {
        struct xdr_stream xdr;
        struct compound_hdr hdr = {
@@ -1470,7 +1447,7 @@ static int nfs4_xdr_enc_remove(struct rpc_rqst *req, __be32 *p, const struct nfs
        encode_compound_hdr(&xdr, &hdr);
        if ((status = encode_putfh(&xdr, args->fh)) != 0)
                goto out;
-       if ((status = encode_remove(&xdr, args->name)) != 0)
+       if ((status = encode_remove(&xdr, &args->name)) != 0)
                goto out;
        status = encode_getfattr(&xdr, args->bitmask);
 out:
@@ -1794,6 +1771,8 @@ static int nfs4_xdr_enc_readlink(struct rpc_rqst *req, __be32 *p, const struct n
        struct compound_hdr hdr = {
                .nops = 2,
        };
+       struct rpc_auth *auth = req->rq_task->tk_msg.rpc_cred->cr_auth;
+       unsigned int replen;
        int status;
 
        xdr_init_encode(&xdr, &req->rq_snd_buf, p);
@@ -1802,6 +1781,15 @@ static int nfs4_xdr_enc_readlink(struct rpc_rqst *req, __be32 *p, const struct n
        if(status)
                goto out;
        status = encode_readlink(&xdr, args, req);
+
+       /* set up reply kvec
+        *    toplevel_status + taglen + rescount + OP_PUTFH + status
+        *      + OP_READLINK + status + string length = 8
+        */
+       replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS4_dec_readlink_sz) << 2;
+       xdr_inline_pages(&req->rq_rcv_buf, replen, args->pages,
+                       args->pgbase, args->pglen);
+
 out:
        return status;
 }
@@ -1815,6 +1803,8 @@ static int nfs4_xdr_enc_readdir(struct rpc_rqst *req, __be32 *p, const struct nf
        struct compound_hdr hdr = {
                .nops = 2,
        };
+       struct rpc_auth *auth = req->rq_task->tk_msg.rpc_cred->cr_auth;
+       int replen;
        int status;
 
        xdr_init_encode(&xdr, &req->rq_snd_buf, p);
@@ -1823,6 +1813,18 @@ static int nfs4_xdr_enc_readdir(struct rpc_rqst *req, __be32 *p, const struct nf
        if(status)
                goto out;
        status = encode_readdir(&xdr, args, req);
+
+       /* set up reply kvec
+        *    toplevel_status + taglen + rescount + OP_PUTFH + status
+        *      + OP_READDIR + status + verifer(2)  = 9
+        */
+       replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS4_dec_readdir_sz) << 2;
+       xdr_inline_pages(&req->rq_rcv_buf, replen, args->pages,
+                        args->pgbase, args->count);
+       dprintk("%s: inlined page args = (%u, %p, %u, %u)\n",
+                       __FUNCTION__, replen, args->pages,
+                       args->pgbase, args->count);
+
 out:
        return status;
 }
@@ -3833,7 +3835,7 @@ out:
 /*
  * Decode REMOVE response
  */
-static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_remove_res *res)
+static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, __be32 *p, struct nfs_removeres *res)
 {
        struct xdr_stream xdr;
        struct compound_hdr hdr;
@@ -3846,7 +3848,7 @@ static int nfs4_xdr_dec_remove(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_re
                goto out;
        if ((status = decode_remove(&xdr, &res->cinfo)) != 0)
                goto out;
-       decode_getfattr(&xdr, res->dir_attr, res->server);
+       decode_getfattr(&xdr, &res->dir_attr, res->server);
 out:
        return status;
 }