Skip to content

Commit c8161f6

Browse files
Eric SandeenLinus Torvalds
authored andcommitted
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>
1 parent c525460 commit c8161f6

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

‎fs/ecryptfs/crypto.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ int ecryptfs_init_crypt_ctx(struct ecryptfs_crypt_stat *crypt_stat)
799799
rc = ecryptfs_crypto_api_algify_cipher_name(&full_alg_name,
800800
crypt_stat->cipher, "cbc");
801801
if (rc)
802-
goto out;
802+
goto out_unlock;
803803
crypt_stat->tfm = crypto_alloc_blkcipher(full_alg_name, 0,
804804
CRYPTO_ALG_ASYNC);
805805
kfree(full_alg_name);
@@ -808,12 +808,12 @@ int ecryptfs_init_crypt_ctx(struct ecryptfs_crypt_stat *crypt_stat)
808808
ecryptfs_printk(KERN_ERR, "cryptfs: init_crypt_ctx(): "
809809
"Error initializing cipher [%s]\n",
810810
crypt_stat->cipher);
811-
mutex_unlock(&crypt_stat->cs_tfm_mutex);
812-
goto out;
811+
goto out_unlock;
813812
}
814813
crypto_blkcipher_set_flags(crypt_stat->tfm, CRYPTO_TFM_REQ_WEAK_KEY);
815-
mutex_unlock(&crypt_stat->cs_tfm_mutex);
816814
rc = 0;
815+
out_unlock:
816+
mutex_unlock(&crypt_stat->cs_tfm_mutex);
817817
out:
818818
return rc;
819819
}

‎fs/ecryptfs/messaging.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ int ecryptfs_init_messaging(unsigned int transport)
427427
if (!ecryptfs_daemon_id_hash) {
428428
rc = -ENOMEM;
429429
ecryptfs_printk(KERN_ERR, "Failed to allocate memory\n");
430+
mutex_unlock(&ecryptfs_daemon_id_hash_mux);
430431
goto out;
431432
}
432433
for (i = 0; i < ecryptfs_hash_buckets; i++)

0 commit comments

Comments
 (0)