Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=8a29f2b0288ba2a8fb302f9a639521ac9ff302e5
Commit:     8a29f2b0288ba2a8fb302f9a639521ac9ff302e5
Parent:     778d1a2bd42ae862a6c6d20a1c3af5e45b3c1924
Author:     Michael Halcrow <[EMAIL PROTECTED]>
AuthorDate: Mon Nov 5 14:51:04 2007 -0800
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Mon Nov 5 15:12:33 2007 -0800

    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 <[EMAIL PROTECTED]>
    Reported-by: Kazuki Ohta <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 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 9ea4769..bbed2fd 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;
 }
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to