]> git.karo-electronics.de Git - linux-beck.git/commitdiff
NFSv4.1: Convert open-coded array allocation calls to kmalloc_array()
authorTrond Myklebust <trond.myklebust@primarydata.com>
Wed, 11 Feb 2015 22:49:13 +0000 (17:49 -0500)
committerTrond Myklebust <trond.myklebust@primarydata.com>
Thu, 12 Feb 2015 00:02:52 +0000 (19:02 -0500)
For added overflow protection...

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
fs/nfs/callback_xdr.c

index 02f8d09e119f4a0bd9d965b994871ff2abc4e210..19ca95cdfd9b0f26aedbbc23f036babf2aeca67a 100644 (file)
@@ -313,7 +313,7 @@ __be32 decode_devicenotify_args(struct svc_rqst *rqstp,
                goto out;
        }
 
-       args->devs = kmalloc(n * sizeof(*args->devs), GFP_KERNEL);
+       args->devs = kmalloc_array(n, sizeof(*args->devs), GFP_KERNEL);
        if (!args->devs) {
                status = htonl(NFS4ERR_DELAY);
                goto out;
@@ -415,7 +415,7 @@ static __be32 decode_rc_list(struct xdr_stream *xdr,
                             rc_list->rcl_nrefcalls * 2 * sizeof(uint32_t));
                if (unlikely(p == NULL))
                        goto out;
-               rc_list->rcl_refcalls = kmalloc(rc_list->rcl_nrefcalls *
+               rc_list->rcl_refcalls = kmalloc_array(rc_list->rcl_nrefcalls,
                                                sizeof(*rc_list->rcl_refcalls),
                                                GFP_KERNEL);
                if (unlikely(rc_list->rcl_refcalls == NULL))