]> git.karo-electronics.de Git - linux-beck.git/commitdiff
NFSv4.1: Fix a kfree() of uninitialised pointers in decode_cb_sequence_args
authorTrond Myklebust <trond.myklebust@primarydata.com>
Wed, 11 Feb 2015 22:27:55 +0000 (17:27 -0500)
committerTrond Myklebust <trond.myklebust@primarydata.com>
Thu, 12 Feb 2015 00:02:51 +0000 (19:02 -0500)
If the call to decode_rc_list() fails due to a memory allocation error,
then we need to truncate the array size to ensure that we only call
kfree() on those pointer that were allocated.

Reported-by: David Ramos <daramos@stanford.edu>
Fixes: 4aece6a19cf7f ("nfs41: cb_sequence xdr implementation")
Cc: stable@vger.kernel.org
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
fs/nfs/callback_xdr.c

index f4ccfe6521ec80f80fd4b9096bcc7ed49ab7d795..02f8d09e119f4a0bd9d965b994871ff2abc4e210 100644 (file)
@@ -464,8 +464,10 @@ static __be32 decode_cb_sequence_args(struct svc_rqst *rqstp,
 
                for (i = 0; i < args->csa_nrclists; i++) {
                        status = decode_rc_list(xdr, &args->csa_rclists[i]);
-                       if (status)
+                       if (status) {
+                               args->csa_nrclists = i;
                                goto out_free;
+                       }
                }
        }
        status = 0;