Message ID | 165823671509.3047.16569036635528856192.stgit@manet.1015granger.net (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | SUNRPC: Fix xdr_encode_bool() | expand |
On Tue, 2022-07-19 at 09:18 -0400, Chuck Lever wrote: > I discovered that xdr_encode_bool() was returning the same address > that was passed in the @p parameter. The documenting comment states > that the intent is to return the address of the next buffer > location, just like the other "xdr_encode_*" helpers. > > The result was the encoded results of NFSv3 PATHCONF operations were > not formed correctly. > > Fixes: ded04a587f6c ("NFSD: Update the NFSv3 PATHCONF3res encoder to use struct xdr_stream") > Signed-off-by: Chuck Lever <chuck.lever@oracle.com> > --- > include/linux/sunrpc/xdr.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h > index 5860f32e3958..986c8a17ca5e 100644 > --- a/include/linux/sunrpc/xdr.h > +++ b/include/linux/sunrpc/xdr.h > @@ -419,8 +419,8 @@ static inline int xdr_stream_encode_item_absent(struct xdr_stream *xdr) > */ > static inline __be32 *xdr_encode_bool(__be32 *p, u32 n) > { > - *p = n ? xdr_one : xdr_zero; > - return p++; > + *p++ = n ? xdr_one : xdr_zero; > + return p; > } > > /** > > Nice catch. Postincrement operators strike again! Reviewed-by: Jeff Layton <jlayton@kernel.org>
> On Jul 19, 2022, at 11:49 AM, Jeff Layton <jlayton@kernel.org> wrote: > > On Tue, 2022-07-19 at 09:18 -0400, Chuck Lever wrote: >> I discovered that xdr_encode_bool() was returning the same address >> that was passed in the @p parameter. The documenting comment states >> that the intent is to return the address of the next buffer >> location, just like the other "xdr_encode_*" helpers. >> >> The result was the encoded results of NFSv3 PATHCONF operations were >> not formed correctly. >> >> Fixes: ded04a587f6c ("NFSD: Update the NFSv3 PATHCONF3res encoder to use struct xdr_stream") >> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> >> --- >> include/linux/sunrpc/xdr.h | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h >> index 5860f32e3958..986c8a17ca5e 100644 >> --- a/include/linux/sunrpc/xdr.h >> +++ b/include/linux/sunrpc/xdr.h >> @@ -419,8 +419,8 @@ static inline int xdr_stream_encode_item_absent(struct xdr_stream *xdr) >> */ >> static inline __be32 *xdr_encode_bool(__be32 *p, u32 n) >> { >> - *p = n ? xdr_one : xdr_zero; >> - return p++; >> + *p++ = n ? xdr_one : xdr_zero; >> + return p; >> } >> >> /** >> >> > > Nice catch. Postincrement operators strike again! The original patch description read "D'oh!". > Reviewed-by: Jeff Layton <jlayton@kernel.org> -- Chuck Lever
diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h index 5860f32e3958..986c8a17ca5e 100644 --- a/include/linux/sunrpc/xdr.h +++ b/include/linux/sunrpc/xdr.h @@ -419,8 +419,8 @@ static inline int xdr_stream_encode_item_absent(struct xdr_stream *xdr) */ static inline __be32 *xdr_encode_bool(__be32 *p, u32 n) { - *p = n ? xdr_one : xdr_zero; - return p++; + *p++ = n ? xdr_one : xdr_zero; + return p; } /**
I discovered that xdr_encode_bool() was returning the same address that was passed in the @p parameter. The documenting comment states that the intent is to return the address of the next buffer location, just like the other "xdr_encode_*" helpers. The result was the encoded results of NFSv3 PATHCONF operations were not formed correctly. Fixes: ded04a587f6c ("NFSD: Update the NFSv3 PATHCONF3res encoder to use struct xdr_stream") Signed-off-by: Chuck Lever <chuck.lever@oracle.com> --- include/linux/sunrpc/xdr.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)