aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Kent <raven@themaw.net>2021-04-09 10:48:23 +0800
committerIan Kent <raven@themaw.net>2021-04-12 13:14:44 +0800
commite1aa6de6dba5b0f4b3b9a94ff56f6045e594190e (patch)
tree046d7865be3e719d8e529ec1aab01aca63da705b
parentf69332596c58b60549c39e92d97a9c030c60eab8 (diff)
downloadautofs-e1aa6de6dba5b0f4b3b9a94ff56f6045e594190e.tar.gz
autofs-5.1.7 - fix possible memory leak in mnts_add_amdmount()
Coverity: leaked_storage: Variable "ext_mp" going out of scope leaks the storage it points to. Same applies to the other duped fields destined for the mnt_list struct. Signed-off-by: Ian Kent <raven@themaw.net>
-rw-r--r--CHANGELOG1
-rw-r--r--lib/mounts.c20
2 files changed, 11 insertions, 10 deletions
diff --git a/CHANGELOG b/CHANGELOG
index b797f6dc..2e3b9fd7 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -53,6 +53,7 @@
- add missing free in handle_mounts().
- remove redundant if check.
- fix possible memory leak in master_parse().
+- fix possible memory leak in mnts_add_amdmount().
25/01/2021 autofs-5.1.7
- make bind mounts propagation slave by default.
diff --git a/lib/mounts.c b/lib/mounts.c
index c8a7bf00..ef69cec1 100644
--- a/lib/mounts.c
+++ b/lib/mounts.c
@@ -1119,16 +1119,16 @@ 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) {
- this->ext_mp = ext_mp;
- this->amd_pref = pref;
- this->amd_type = type;
- this->amd_opts = opts;
- this->amd_cache_opts = entry->cache_opts;
- this->flags |= MNTS_AMD_MOUNT;
- if (list_empty(&this->amdmount))
- list_add_tail(&this->amdmount, &ap->amdmounts);
- }
+ if (!this)
+ goto fail;
+ this->ext_mp = ext_mp;
+ this->amd_pref = pref;
+ this->amd_type = type;
+ this->amd_opts = opts;
+ this->amd_cache_opts = entry->cache_opts;
+ this->flags |= MNTS_AMD_MOUNT;
+ if (list_empty(&this->amdmount))
+ list_add_tail(&this->amdmount, &ap->amdmounts);
mnts_hash_mutex_unlock();
return this;