Commit c8161f64ccdcc3ac05c7bbfebc031e7ad5ca6412

Authored by Eric Sandeen
Committed by Linus Torvalds
1 parent c525460e27

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: Eric Sandeen <sandeen@redhat.com>
Cc: Josef Bacik <jbacik@redhat.com>
Cc: Michael Halcrow <mhalcrow@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 2 changed files with 5 additions and 4 deletions Side-by-side Diff

fs/ecryptfs/crypto.c
... ... @@ -799,7 +799,7 @@
799 799 rc = ecryptfs_crypto_api_algify_cipher_name(&full_alg_name,
800 800 crypt_stat->cipher, "cbc");
801 801 if (rc)
802   - goto out;
  802 + goto out_unlock;
803 803 crypt_stat->tfm = crypto_alloc_blkcipher(full_alg_name, 0,
804 804 CRYPTO_ALG_ASYNC);
805 805 kfree(full_alg_name);
806 806  
807 807  
... ... @@ -808,12 +808,12 @@
808 808 ecryptfs_printk(KERN_ERR, "cryptfs: init_crypt_ctx(): "
809 809 "Error initializing cipher [%s]\n",
810 810 crypt_stat->cipher);
811   - mutex_unlock(&crypt_stat->cs_tfm_mutex);
812   - goto out;
  811 + goto out_unlock;
813 812 }
814 813 crypto_blkcipher_set_flags(crypt_stat->tfm, CRYPTO_TFM_REQ_WEAK_KEY);
815   - mutex_unlock(&crypt_stat->cs_tfm_mutex);
816 814 rc = 0;
  815 +out_unlock:
  816 + mutex_unlock(&crypt_stat->cs_tfm_mutex);
817 817 out:
818 818 return rc;
819 819 }
fs/ecryptfs/messaging.c
... ... @@ -427,6 +427,7 @@
427 427 if (!ecryptfs_daemon_id_hash) {
428 428 rc = -ENOMEM;
429 429 ecryptfs_printk(KERN_ERR, "Failed to allocate memory\n");
  430 + mutex_unlock(&ecryptfs_daemon_id_hash_mux);
430 431 goto out;
431 432 }
432 433 for (i = 0; i < ecryptfs_hash_buckets; i++)