autofs-5.1.9 - always set ap for mnt_list entries

From: Ian Kent <raven@themaw.net>

Saving the owning struct autofs_point will prove useful when enumerating
mounted mounts with the cli utility so set it in struct mnt_list when
they are added.

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

diff --git a/CHANGELOG b/CHANGELOG
index b18d360dd..be7f1347a 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -98,6 +98,7 @@
 - make open_mutex usage more consistent at process spawn.
 - remove mount point directory at umount if we created it.
 - remove directory cleanup umount_multi().
+- always set ap for mnt_list entries.
 
 02/11/2023 autofs-5.1.9
 - fix kernel mount status notification.
diff --git a/lib/mounts.c b/lib/mounts.c
index 736f65f3d..741dbdf45 100644
--- a/lib/mounts.c
+++ b/lib/mounts.c
@@ -1238,6 +1238,8 @@ struct mnt_list *mnts_add_amdmount(struct autofs_point *ap, struct amd_entry *en
 		mnts_hash_mutex_unlock();
 		goto fail;
 	}
+	if (!this->ap)
+		this->ap = ap;
 	this->ext_mp = ext_mp;
 	this->amd_pref = pref;
 	this->amd_type = type;
@@ -1341,6 +1343,8 @@ struct mnt_list *mnts_add_mount(struct autofs_point *ap,
 	mnts_hash_mutex_lock();
 	this = mnts_get_mount(mp);
 	if (this) {
+		if (!this->ap)
+			this->ap = ap;
 		this->flags |= flags;
 		if ((this->flags & MNTS_MOUNTED) && list_empty(&this->mount))
 			list_add(&this->mount, &ap->mounts);
