Blame SOURCES/autofs-5.1.7-fix-possible-memory-leak-in-mnts_add_amdmount.patch

beb904
autofs-5.1.7 - fix possible memory leak in mnts_add_amdmount()
beb904
beb904
From: Ian Kent <raven@themaw.net>
beb904
beb904
Coverity: leaked_storage: Variable "ext_mp" going out of scope leaks
beb904
	  the storage it points to.
beb904
beb904
Same applies to the other duped fields destined for the mnt_list struct.
beb904
beb904
Signed-off-by: Ian Kent <raven@themaw.net>
beb904
---
beb904
 CHANGELOG    |    1 +
beb904
 lib/mounts.c |   20 ++++++++++----------
beb904
 2 files changed, 11 insertions(+), 10 deletions(-)
beb904
beb904
--- autofs-5.1.4.orig/CHANGELOG
beb904
+++ autofs-5.1.4/CHANGELOG
beb904
@@ -53,6 +53,7 @@
beb904
 - add missing free in handle_mounts().
beb904
 - remove redundant if check.
beb904
 - fix possible memory leak in master_parse().
beb904
+- fix possible memory leak in mnts_add_amdmount().
beb904
 
beb904
 xx/xx/2018 autofs-5.1.5
beb904
 - fix flag file permission.
beb904
--- autofs-5.1.4.orig/lib/mounts.c
beb904
+++ autofs-5.1.4/lib/mounts.c
beb904
@@ -1119,16 +1119,16 @@ struct mnt_list *mnts_add_amdmount(struc
beb904
 
beb904
 	mnts_hash_mutex_lock();
beb904
 	this = mnts_get_mount(entry->path);
beb904
-	if (this) {
beb904
-		this->ext_mp = ext_mp;
beb904
-		this->amd_pref = pref;
beb904
-		this->amd_type = type;
beb904
-		this->amd_opts = opts;
beb904
-		this->amd_cache_opts = entry->cache_opts;
beb904
-		this->flags |= MNTS_AMD_MOUNT;
beb904
-		if (list_empty(&this->amdmount))
beb904
-			list_add_tail(&this->amdmount, &ap->amdmounts);
beb904
-	}
beb904
+	if (!this)
beb904
+		goto fail;
beb904
+	this->ext_mp = ext_mp;
beb904
+	this->amd_pref = pref;
beb904
+	this->amd_type = type;
beb904
+	this->amd_opts = opts;
beb904
+	this->amd_cache_opts = entry->cache_opts;
beb904
+	this->flags |= MNTS_AMD_MOUNT;
beb904
+	if (list_empty(&this->amdmount))
beb904
+		list_add_tail(&this->amdmount, &ap->amdmounts);
beb904
 	mnts_hash_mutex_unlock();
beb904
 
beb904
 	return this;