mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Silence 'may be used uninitialized' warning in fs/nfs/callback_xdr.c
@ 2008-04-24  4:22 Tony Breeds
  0 siblings, 0 replies; only message in thread
From: Tony Breeds @ 2008-04-24  4:22 UTC (permalink / raw)
  To: Trond Myklebust, linux-nfs; +Cc: Linux Kernel ML, Andrew Morton

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.

Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
---
 fs/nfs/callback_xdr.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
index 13619d2..d26af3e 100644
--- a/fs/nfs/callback_xdr.c
+++ b/fs/nfs/callback_xdr.c
@@ -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);
-- 
1.5.5.1



Yours Tony

  linux.conf.au    http://www.marchsouth.org/
  Jan 19 - 24 2009 The Australian Linux Technical Conference!


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-04-24  4:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-24  4:22 [PATCH] Silence 'may be used uninitialized' warning in fs/nfs/callback_xdr.c Tony Breeds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®