Silence 'may be used uninitialized' warning in fs/nfs/callback_xdr.c
Subsystems (2)
PATCH 1/1 Silence 'may be used uninitialized' warning in fs/nfs/callback_xdr.c
Currently the kernel will issue the following warnings:
fs/nfs/callback_xdr.c: In function 'nfs4_callback_compound':fs/nfs/callback_xdr.c:404: warning: 'hdr_arg.taglen' may be used uninitialized in this function fs/nfs/callback_xdr.c:404: warning: 'hdr_arg.tag' may be used uninitialized in this function fs/nfs/callback_xdr.c:404: warning: 'hdr_arg.nops' may be used uninitialized in this function
It seems that call chain look something like:nfs4_callback_compound()
-> decode_compound_hdr_arg()
-> decode_string() which may fail and return NFS4ERR_RESOURCE.
Which decode_compound_hdr_arg() passes on. Unfortunately nfs4_callback_compound() doesn't check this status and cheerfully uses hdr_arg which is basically stack garbage. The same problem seems to apply to encode_compound_hdr_res().
Check the return values, and explictly tell gcc to silence that warning.
--- fs/nfs/callback_xdr.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)
fs/nfs/callback_xdr.c +7 -3
@@ -401,7 +401,7 @@ static __be32 process_op(struct svc_rqst *rqstp,*/ static __be32 nfs4_callback_compound (struct svc_rqst *rqstp,void *argp,void *resp) { -struct cb_compound_hdr_arg hdr_arg; +struct cb_compound_hdr_arg uninitialized_var (hdr_arg );struct cb_compound_hdr_res hdr_res;struct xdr_stream xdr_in, xdr_out;__be32 *p;
@@ -415,11 +415,15 @@ static __be32 nfs4_callback_compound(struct svc_rqst *rqstp, void *argp, void *r p = (__be32 *)((char *)rqstp->rq_res.head[0 ].iov_base + rqstp->rq_res.head[0 ].iov_len);xdr_init_encode (&xdr_out, &rqstp->rq_res, p); -decode_compound_hdr_arg (&xdr_in, &hdr_arg); + status =decode_compound_hdr_arg (&xdr_in, &hdr_arg); +if (unlikely (status !=0 )) +return status; hdr_res.taglen = hdr_arg.taglen; hdr_res.tag = hdr_arg.tag; hdr_res.nops =NULL ; -encode_compound_hdr_res (&xdr_out, &hdr_res); + status =encode_compound_hdr_res (&xdr_out, &hdr_res); +if (unlikely (status !=0 )) +return status;for (;;) { status =process_op (rqstp, &xdr_in, argp, &xdr_out, resp);
Signature · 8 lines
1.5.5.1 Yours Tony linux.conf.au http://www.marchsouth.org/ Jan 19 - 24 2009 The Australian Linux Technical Conference!