Commit c8161f64 authored by Eric Sandeen's avatar Eric Sandeen Committed by Linus Torvalds

ecryptfs: fix unlocking in error paths

Thanks to Josef Bacik for finding these.

A couple of ecryptfs error paths don't properly unlock things they locked.
Signed-off-by: default avatarEric Sandeen <sandeen@redhat.com>
Cc: Josef Bacik <jbacik@redhat.com>
Cc: Michael Halcrow <mhalcrow@us.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent c525460e
...@@ -799,7 +799,7 @@ int ecryptfs_init_crypt_ctx(struct ecryptfs_crypt_stat *crypt_stat) ...@@ -799,7 +799,7 @@ int ecryptfs_init_crypt_ctx(struct ecryptfs_crypt_stat *crypt_stat)
rc = ecryptfs_crypto_api_algify_cipher_name(&full_alg_name, rc = ecryptfs_crypto_api_algify_cipher_name(&full_alg_name,
crypt_stat->cipher, "cbc"); crypt_stat->cipher, "cbc");
if (rc) if (rc)
goto out; goto out_unlock;
crypt_stat->tfm = crypto_alloc_blkcipher(full_alg_name, 0, crypt_stat->tfm = crypto_alloc_blkcipher(full_alg_name, 0,
CRYPTO_ALG_ASYNC); CRYPTO_ALG_ASYNC);
kfree(full_alg_name); kfree(full_alg_name);
...@@ -808,12 +808,12 @@ int ecryptfs_init_crypt_ctx(struct ecryptfs_crypt_stat *crypt_stat) ...@@ -808,12 +808,12 @@ int ecryptfs_init_crypt_ctx(struct ecryptfs_crypt_stat *crypt_stat)
ecryptfs_printk(KERN_ERR, "cryptfs: init_crypt_ctx(): " ecryptfs_printk(KERN_ERR, "cryptfs: init_crypt_ctx(): "
"Error initializing cipher [%s]\n", "Error initializing cipher [%s]\n",
crypt_stat->cipher); crypt_stat->cipher);
mutex_unlock(&crypt_stat->cs_tfm_mutex); goto out_unlock;
goto out;
} }
crypto_blkcipher_set_flags(crypt_stat->tfm, CRYPTO_TFM_REQ_WEAK_KEY); crypto_blkcipher_set_flags(crypt_stat->tfm, CRYPTO_TFM_REQ_WEAK_KEY);
mutex_unlock(&crypt_stat->cs_tfm_mutex);
rc = 0; rc = 0;
out_unlock:
mutex_unlock(&crypt_stat->cs_tfm_mutex);
out: out:
return rc; return rc;
} }
......
...@@ -427,6 +427,7 @@ int ecryptfs_init_messaging(unsigned int transport) ...@@ -427,6 +427,7 @@ int ecryptfs_init_messaging(unsigned int transport)
if (!ecryptfs_daemon_id_hash) { if (!ecryptfs_daemon_id_hash) {
rc = -ENOMEM; rc = -ENOMEM;
ecryptfs_printk(KERN_ERR, "Failed to allocate memory\n"); ecryptfs_printk(KERN_ERR, "Failed to allocate memory\n");
mutex_unlock(&ecryptfs_daemon_id_hash_mux);
goto out; goto out;
} }
for (i = 0; i < ecryptfs_hash_buckets; i++) for (i = 0; i < ecryptfs_hash_buckets; i++)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment