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

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