* [PATCH] eCryptfs: Release mutex on hash error path
[not found] <b82310160710282310v369cc6f9uf544fa3daadd2743@mail.gmail.com>
@ 2007-11-02 20:51 ` Michael Halcrow
0 siblings, 0 replies; only message in thread
From: Michael Halcrow @ 2007-11-02 20:51 UTC (permalink / raw)
To: Andrew Morton; +Cc: phillip, ecryptfs-devel, Kazuki Ohta, LKML
On Mon, Oct 29, 2007 at 03:10:09PM +0900, Kazuki Ohta wrote:
> When IS_ERR(desc.tfm) is true, unlocking
> crypt_stat->cs_hash_tfm_mutex is forgotten.
Thanks for reporting this, Kazuki.
---
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>
---
fs/ecryptfs/crypto.c | 26 ++++++++++++++++++++++----
1 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index a0f53aa..70f7aab 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -115,11 +115,29 @@ static int ecryptfs_calculate_md5(char *dst,
}
crypt_stat->hash_tfm = desc.tfm;
}
- crypto_hash_init(&desc);
- crypto_hash_update(&desc, &sg, len);
- crypto_hash_final(&desc, dst);
- mutex_unlock(&crypt_stat->cs_hash_tfm_mutex);
+ rc = crypto_hash_init(&desc);
+ if (rc) {
+ printk(KERN_ERR
+ "%s: Error initializing crypto hash; rc = [%d]\n",
+ __FUNCTION__, rc);
+ goto out;
+ }
+ rc = crypto_hash_update(&desc, &sg, len);
+ if (rc) {
+ printk(KERN_ERR
+ "%s: Error updating crypto hash; rc = [%d]\n",
+ __FUNCTION__, rc);
+ goto out;
+ }
+ rc = crypto_hash_final(&desc, dst);
+ if (rc) {
+ printk(KERN_ERR
+ "%s: Error finalizing crypto hash; rc = [%d]\n",
+ __FUNCTION__, rc);
+ goto out;
+ }
out:
+ mutex_unlock(&crypt_stat->cs_hash_tfm_mutex);
return rc;
}
--
1.5.0.6
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2007-11-02 20:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <b82310160710282310v369cc6f9uf544fa3daadd2743@mail.gmail.com>
2007-11-02 20:51 ` [PATCH] eCryptfs: Release mutex on hash error path Michael Halcrow
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.