diff options
Diffstat (limited to 'fs/ecryptfs')
-rw-r--r-- | fs/ecryptfs/crypto.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c index 9d70289f7df3..bbed2fd40fdc 100644 --- a/fs/ecryptfs/crypto.c +++ b/fs/ecryptfs/crypto.c | |||
@@ -115,11 +115,29 @@ static int ecryptfs_calculate_md5(char *dst, | |||
115 | } | 115 | } |
116 | crypt_stat->hash_tfm = desc.tfm; | 116 | crypt_stat->hash_tfm = desc.tfm; |
117 | } | 117 | } |
118 | crypto_hash_init(&desc); | 118 | rc = crypto_hash_init(&desc); |
119 | crypto_hash_update(&desc, &sg, len); | 119 | if (rc) { |
120 | crypto_hash_final(&desc, dst); | 120 | printk(KERN_ERR |
121 | mutex_unlock(&crypt_stat->cs_hash_tfm_mutex); | 121 | "%s: Error initializing crypto hash; rc = [%d]\n", |
122 | __FUNCTION__, rc); | ||
123 | goto out; | ||
124 | } | ||
125 | rc = crypto_hash_update(&desc, &sg, len); | ||
126 | if (rc) { | ||
127 | printk(KERN_ERR | ||
128 | "%s: Error updating crypto hash; rc = [%d]\n", | ||
129 | __FUNCTION__, rc); | ||
130 | goto out; | ||
131 | } | ||
132 | rc = crypto_hash_final(&desc, dst); | ||
133 | if (rc) { | ||
134 | printk(KERN_ERR | ||
135 | "%s: Error finalizing crypto hash; rc = [%d]\n", | ||
136 | __FUNCTION__, rc); | ||
137 | goto out; | ||
138 | } | ||
122 | out: | 139 | out: |
140 | mutex_unlock(&crypt_stat->cs_hash_tfm_mutex); | ||
123 | return rc; | 141 | return rc; |
124 | } | 142 | } |
125 | 143 | ||
@@ -504,7 +522,6 @@ int ecryptfs_encrypt_page(struct page *page) | |||
504 | "\n", rc); | 522 | "\n", rc); |
505 | goto out; | 523 | goto out; |
506 | } | 524 | } |
507 | extent_offset++; | ||
508 | } | 525 | } |
509 | out: | 526 | out: |
510 | kfree(enc_extent_virt); | 527 | kfree(enc_extent_virt); |
@@ -640,7 +657,6 @@ int ecryptfs_decrypt_page(struct page *page) | |||
640 | "rc = [%d]\n", __FUNCTION__, rc); | 657 | "rc = [%d]\n", __FUNCTION__, rc); |
641 | goto out; | 658 | goto out; |
642 | } | 659 | } |
643 | extent_offset++; | ||
644 | } | 660 | } |
645 | out: | 661 | out: |
646 | kfree(enc_extent_virt); | 662 | kfree(enc_extent_virt); |