Add stable@vger.kernel.org annotations
[ext4-patch-queue.git] / return-error-code-on-key-retrieval-failure-and-retry-crypto-after-interrupted
blob41e12897c90521459b6e0e32ea69615da86b6902
1 ext4 crypto: Return error code on key retrieval failure and retry crypto after interrupted
3 From: Michael Halcrow <mhalcrow@google.com>
5 Signed-of-by: Michael Halcrow <mhalcrow@google.com>
6 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
7 ---
8  fs/ext4/crypto.c | 5 ++++-
9  1 file changed, 4 insertions(+), 1 deletion(-)
11 diff --git a/fs/ext4/crypto.c b/fs/ext4/crypto.c
12 index f81b804..ead3111 100644
13 --- a/fs/ext4/crypto.c
14 +++ b/fs/ext4/crypto.c
15 @@ -629,7 +629,7 @@ static int ext4_get_wrapping_key(
16         }
17         BUG_ON(sig[EXT4_WRAPPING_KEY_SIG_NULL_TERMINATED_SIZE - 1] != '\0');
18         res = ext4_get_wrapping_key_from_keyring(wrapping_key, sig);
19 -       return 0;
20 +       return res;
21  }
23  /**
24 @@ -1048,6 +1048,7 @@ int ext4_set_crypto_key(struct dentry *dentry)
25         struct ext4_inode_info *ei = EXT4_I(inode);
26         int res = 0;
28 +try_again:
29         ext4_generate_encryption_key(dentry);
30         res = ext4_wrap_key(wrapped_key_packet, &wrapped_key_packet_size,
31                             &ei->i_encryption_key, inode);
32 @@ -1062,6 +1063,8 @@ int ext4_set_crypto_key(struct dentry *dentry)
33                              root_packet, root_packet_size, 0);
34  out:
35         if (res) {
36 +               if (res == -EINTR)
37 +                       goto try_again;
38                 ei->i_encryption_key.mode = EXT4_ENCRYPTION_MODE_INVALID;
39                 printk_ratelimited(KERN_ERR "%s: res = [%d]\n", __func__, res);
40         }
41 -- 
42 2.1.0.rc2.206.gedb03e5