From 40ebefb516c1d1780f411e07e36d74e2d902b3a2 Mon Sep 17 00:00:00 2001 From: Noriko Hosoi Date: Mon, 4 Apr 2016 17:23:16 -0700 Subject: [PATCH] Ticket #48374 - entry cache locks not released in error conditions Description: Ludwig Krispenz found 2 missing unlocks in the cache.c code. This patch is created based upon his report. I also scanned the code and did not find further mistakes. https://fedorahosted.org/389/ticket/48374 Reviewed by nhosoi@redhat.com. --- ldap/servers/slapd/back-ldbm/cache.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ldap/servers/slapd/back-ldbm/cache.c b/ldap/servers/slapd/back-ldbm/cache.c index f6a9cf5..9db51e9 100644 --- a/ldap/servers/slapd/back-ldbm/cache.c +++ b/ldap/servers/slapd/back-ldbm/cache.c @@ -1049,7 +1049,7 @@ static int entrycache_replace(struct cache *cache, struct backentry *olde, if (!add_hash(cache->c_dntable, (void *)newndn, strlen(newndn), newe, (void **)&alte)) { LOG("entry cache replace (%s): can't add to dn table (returned %s)\n", newndn, alte?slapi_entry_get_dn(alte->ep_entry):"none", 0); - cache_lock(cache); + cache_unlock(cache); return 1; } if (!add_hash(cache->c_idtable, &(newe->ep_id), sizeof(ID), newe, (void **)&alte)) { @@ -1507,6 +1507,7 @@ int cache_lock_entry(struct cache *cache, struct backentry *e) if (! e->ep_mutexp) { e->ep_mutexp = PR_NewMonitor(); if (!e->ep_mutexp) { + PR_Unlock(cache->c_emutexalloc_mutex); LOG("<= cache_lock_entry (DELETED)\n", 0, 0, 0); LDAPDebug1Arg(LDAP_DEBUG_ANY, "cache_lock_entry: failed to create a lock for %s\n", -- 2.4.3