autofs-5.1.9 - fix lock not released on error in mnts_add_amdmount()

From: Ian Kent <raven@themaw.net>

The mnts_hash_mutex is not released on exit if an allocation failure
occurs.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG    |    1 +
 lib/mounts.c |    4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG b/CHANGELOG
index 33784c85d..ae8730de3 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -30,6 +30,7 @@
 - handle sss special case getautomntbyname() error.
 - fix deadlock in master_notify_submount().
 - remove mounts_mutex macros.
+- fix lock not released on error in mnts_add_amdmount().
 
 02/11/2023 autofs-5.1.9
 - fix kernel mount status notification.
diff --git a/lib/mounts.c b/lib/mounts.c
index 0818bc269..6bd9cff27 100644
--- a/lib/mounts.c
+++ b/lib/mounts.c
@@ -1189,8 +1189,10 @@ struct mnt_list *mnts_add_amdmount(struct autofs_point *ap, struct amd_entry *en
 
 	mnts_hash_mutex_lock();
 	this = mnts_get_mount(entry->path);
-	if (!this)
+	if (!this) {
+		mnts_hash_mutex_unlock();
 		goto fail;
+	}
 	this->ext_mp = ext_mp;
 	this->amd_pref = pref;
 	this->amd_type = type;
