Merge tag 'nfs-for-4.19-1' of git://git.linux-nfs.org/projects/anna/linux-nfs
[sfrench/cifs-2.6.git] / net / sunrpc / auth_gss / gss_krb5_crypto.c
index a1acee106faa9f8a9c3b4d4b84bb5a3aa039b521..0220e1ca52806d76289f5c8b37558e111fbf35c9 100644 (file)
@@ -169,7 +169,7 @@ make_checksum_hmac_md5(struct krb5_ctx *kctx, char *header, int hdrlen,
        struct scatterlist              sg[1];
        int err = -1;
        u8 *checksumdata;
-       u8 rc4salt[4];
+       u8 *rc4salt;
        struct crypto_ahash *md5;
        struct crypto_ahash *hmac_md5;
        struct ahash_request *req;
@@ -183,14 +183,18 @@ make_checksum_hmac_md5(struct krb5_ctx *kctx, char *header, int hdrlen,
                return GSS_S_FAILURE;
        }
 
+       rc4salt = kmalloc_array(4, sizeof(*rc4salt), GFP_NOFS);
+       if (!rc4salt)
+               return GSS_S_FAILURE;
+
        if (arcfour_hmac_md5_usage_to_salt(usage, rc4salt)) {
                dprintk("%s: invalid usage value %u\n", __func__, usage);
-               return GSS_S_FAILURE;
+               goto out_free_rc4salt;
        }
 
        checksumdata = kmalloc(GSS_KRB5_MAX_CKSUM_LEN, GFP_NOFS);
        if (!checksumdata)
-               return GSS_S_FAILURE;
+               goto out_free_rc4salt;
 
        md5 = crypto_alloc_ahash("md5", 0, CRYPTO_ALG_ASYNC);
        if (IS_ERR(md5))
@@ -258,6 +262,8 @@ out_free_md5:
        crypto_free_ahash(md5);
 out_free_cksum:
        kfree(checksumdata);
+out_free_rc4salt:
+       kfree(rc4salt);
        return err ? GSS_S_FAILURE : 0;
 }
 
@@ -373,7 +379,6 @@ make_checksum_v2(struct krb5_ctx *kctx, char *header, int hdrlen,
        struct scatterlist sg[1];
        int err = -1;
        u8 *checksumdata;
-       unsigned int checksumlen;
 
        if (kctx->gk5e->keyed_cksum == 0) {
                dprintk("%s: expected keyed hash for %s\n",
@@ -393,7 +398,6 @@ make_checksum_v2(struct krb5_ctx *kctx, char *header, int hdrlen,
        tfm = crypto_alloc_ahash(kctx->gk5e->cksum_name, 0, CRYPTO_ALG_ASYNC);
        if (IS_ERR(tfm))
                goto out_free_cksum;
-       checksumlen = crypto_ahash_digestsize(tfm);
 
        req = ahash_request_alloc(tfm, GFP_NOFS);
        if (!req)