diff mbox series

[v1,58/61] NFSD: Replace READ* macros in nfsd4_decode_setxattr()

Message ID 160528004877.6186.2667946875923803861.stgit@klimt.1015granger.net (mailing list archive)
State New, archived
Headers show
Series Update NFSD XDR functions | expand

Commit Message

Chuck Lever Nov. 13, 2020, 3:07 p.m. UTC
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 fs/nfsd/nfs4xdr.c |   22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 12b90251fbf5..760aac341fab 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -2261,25 +2261,25 @@  static __be32
 nfsd4_decode_setxattr(struct nfsd4_compoundargs *argp,
 		      struct nfsd4_setxattr *setxattr)
 {
-	DECODE_HEAD;
 	u32 flags, maxcount, size;
+	__be32 status;
 
-	READ_BUF(4);
-	flags = be32_to_cpup(p++);
+	if (xdr_stream_decode_u32(argp->xdr, &flags) < 0)
+		goto xdr_error;
 
 	if (flags > SETXATTR4_REPLACE)
-		return nfserr_inval;
+		goto inval_arg;
 	setxattr->setxa_flags = flags;
 
 	status = nfsd4_decode_xattr_name(argp, &setxattr->setxa_name);
 	if (status)
-		return status;
+		goto out;
 
 	maxcount = svc_max_payload(argp->rqstp);
 	maxcount = min_t(u32, XATTR_SIZE_MAX, maxcount);
 
-	READ_BUF(4);
-	size = be32_to_cpup(p++);
+	if (xdr_stream_decode_u32(argp->xdr, &size) < 0)
+		goto xdr_error;
 	if (size > maxcount)
 		return nfserr_xattr2big;
 
@@ -2293,7 +2293,13 @@  nfsd4_decode_setxattr(struct nfsd4_compoundargs *argp,
 						&setxattr->setxa_buf, size);
 	}
 
-	DECODE_TAIL;
+	status = nfs_ok;
+out:
+	return status;
+xdr_error:
+	return nfserr_bad_xdr;
+inval_arg:
+	return nfserr_inval;
 }
 
 static __be32