aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorMichael Halcrow <mhalcrow@us.ibm.com>2007-11-05 17:51:04 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-11-05 18:12:33 -0500
commit8a29f2b0288ba2a8fb302f9a639521ac9ff302e5 (patch)
tree384f27ea6300fe50345b0ab5cd7fdad23d0bdb79 /fs
parent778d1a2bd42ae862a6c6d20a1c3af5e45b3c1924 (diff)
eCryptfs: release mutex on hash error path
Release the crypt_stat hash mutex on allocation error. Check for error conditions when doing crypto hash calls. Signed-off-by: Michael Halcrow <mhalcrow@us.ibm.com> Reported-by: Kazuki Ohta <kazuki.ohta@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/ecryptfs/crypto.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index 9ea4769fbb66..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 }
122out: 139out:
140 mutex_unlock(&crypt_stat->cs_hash_tfm_mutex);
123 return rc; 141 return rc;
124} 142}
125 143