]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ecryptfs: remove redundant variable found_auth_tok
authorAlexey Velichayshiy <a.velichayshiy@ispras.ru>
Sun, 12 Apr 2026 13:50:08 +0000 (16:50 +0300)
committerTyler Hicks <code@tyhicks.com>
Mon, 11 May 2026 14:53:14 +0000 (09:53 -0500)
The found_auth_tok variable is no longer needed, as the fact of finding
a token is determined directly by jumping to the found_matching_auth_tok
label inside the loop.

Remove found_auth_tok, simplifying the function logic.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Alexey Velichayshiy <a.velichayshiy@ispras.ru>
[tyhicks: Unsplit log message string]
Signed-off-by: Tyler Hicks <code@tyhicks.com>
fs/ecryptfs/keystore.c

index 0be746493e560f5f2585685f48099616897cc840..ebebc9551f1ff82eaeb535930811a0939770ed72 100644 (file)
@@ -1718,7 +1718,6 @@ int ecryptfs_parse_packet_set(struct ecryptfs_crypt_stat *crypt_stat,
                              struct dentry *ecryptfs_dentry)
 {
        size_t i = 0;
-       size_t found_auth_tok;
        size_t next_packet_is_auth_tok_packet;
        LIST_HEAD(auth_tok_list);
        struct ecryptfs_auth_tok *matching_auth_tok;
@@ -1822,7 +1821,6 @@ int ecryptfs_parse_packet_set(struct ecryptfs_crypt_stat *crypt_stat,
         * the metadata. There may be several potential matches, but
         * just one will be sufficient to decrypt to get the FEK. */
 find_next_matching_auth_tok:
-       found_auth_tok = 0;
        list_for_each_entry(auth_tok_list_item, &auth_tok_list, list) {
                candidate_auth_tok = &auth_tok_list_item->auth_tok;
                if (unlikely(ecryptfs_verbosity > 0)) {
@@ -1843,17 +1841,13 @@ find_next_matching_auth_tok:
                                               &matching_auth_tok,
                                               crypt_stat->mount_crypt_stat,
                                               candidate_auth_tok_sig);
-               if (!rc) {
-                       found_auth_tok = 1;
+               if (!rc)
                        goto found_matching_auth_tok;
-               }
-       }
-       if (!found_auth_tok) {
-               ecryptfs_printk(KERN_ERR, "Could not find a usable "
-                               "authentication token\n");
-               rc = -EIO;
-               goto out_wipe_list;
        }
+       ecryptfs_printk(KERN_ERR,
+                       "Could not find a usable authentication token\n");
+       rc = -EIO;
+       goto out_wipe_list;
 found_matching_auth_tok:
        if (candidate_auth_tok->token_type == ECRYPTFS_PRIVATE_KEY) {
                memcpy(&(candidate_auth_tok->token.private_key),