Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Michael Halcrow and committed by
Linus Torvalds
8a29f2b0 778d1a2b

+22 -4
+22 -4
fs/ecryptfs/crypto.c
··· 115 115 } 116 116 crypt_stat->hash_tfm = desc.tfm; 117 117 } 118 - crypto_hash_init(&desc); 119 - crypto_hash_update(&desc, &sg, len); 120 - crypto_hash_final(&desc, dst); 121 - mutex_unlock(&crypt_stat->cs_hash_tfm_mutex); 118 + rc = crypto_hash_init(&desc); 119 + if (rc) { 120 + printk(KERN_ERR 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 139 out: 140 + mutex_unlock(&crypt_stat->cs_hash_tfm_mutex); 123 141 return rc; 124 142 } 125 143