Merge tag 'locking-core-2020-06-01' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-microblaze.git] / fs / ubifs / replay.c
index b28ac4d..b69ffac 100644 (file)
@@ -558,7 +558,7 @@ static int is_last_bud(struct ubifs_info *c, struct ubifs_bud *bud)
        return data == 0xFFFFFFFF;
 }
 
-/* authenticate_sleb_hash and authenticate_sleb_hmac are split out for stack usage */
+/* authenticate_sleb_hash is split out for stack usage */
 static int authenticate_sleb_hash(struct ubifs_info *c, struct shash_desc *log_hash, u8 *hash)
 {
        SHASH_DESC_ON_STACK(hash_desc, c->hash_tfm);
@@ -569,15 +569,6 @@ static int authenticate_sleb_hash(struct ubifs_info *c, struct shash_desc *log_h
        return crypto_shash_final(hash_desc, hash);
 }
 
-static int authenticate_sleb_hmac(struct ubifs_info *c, u8 *hash, u8 *hmac)
-{
-       SHASH_DESC_ON_STACK(hmac_desc, c->hmac_tfm);
-
-       hmac_desc->tfm = c->hmac_tfm;
-
-       return crypto_shash_digest(hmac_desc, hash, c->hash_len, hmac);
-}
-
 /**
  * authenticate_sleb - authenticate one scan LEB
  * @c: UBIFS file-system description object
@@ -601,18 +592,12 @@ static int authenticate_sleb(struct ubifs_info *c, struct ubifs_scan_leb *sleb,
        struct ubifs_scan_node *snod;
        int n_nodes = 0;
        int err;
-       u8 *hash, *hmac;
+       u8 hash[UBIFS_HASH_ARR_SZ];
+       u8 hmac[UBIFS_HMAC_ARR_SZ];
 
        if (!ubifs_authenticated(c))
                return sleb->nodes_cnt;
 
-       hash = kmalloc(crypto_shash_descsize(c->hash_tfm), GFP_NOFS);
-       hmac = kmalloc(c->hmac_desc_len, GFP_NOFS);
-       if (!hash || !hmac) {
-               err = -ENOMEM;
-               goto out;
-       }
-
        list_for_each_entry(snod, &sleb->nodes, list) {
 
                n_nodes++;
@@ -624,7 +609,8 @@ static int authenticate_sleb(struct ubifs_info *c, struct ubifs_scan_leb *sleb,
                        if (err)
                                goto out;
 
-                       err = authenticate_sleb_hmac(c, hash, hmac);
+                       err = crypto_shash_tfm_digest(c->hmac_tfm, hash,
+                                                     c->hash_len, hmac);
                        if (err)
                                goto out;
 
@@ -662,9 +648,6 @@ static int authenticate_sleb(struct ubifs_info *c, struct ubifs_scan_leb *sleb,
                err = 0;
        }
 out:
-       kfree(hash);
-       kfree(hmac);
-
        return err ? err : n_nodes - n_not_auth;
 }