Blame SOURCES/autofs-5.1.8-fix-memory-leak-in-update_hosts_mounts.patch

de1ab5
autofs-5.1.8 - fix memory leak in update_hosts_mounts()
de1ab5
de1ab5
From: Ian Kent <raven@themaw.net>
de1ab5
de1ab5
Coverity has reported a memory leak in update_hosts_mounts() introduced
de1ab5
by the map reload deadlock fix.
de1ab5
de1ab5
Signed-off-by: Ian Kent <raven@themaw.net>
de1ab5
---
de1ab5
 CHANGELOG              |    1 +
de1ab5
 modules/lookup_hosts.c |   13 +++++++------
de1ab5
 2 files changed, 8 insertions(+), 6 deletions(-)
de1ab5
de1ab5
--- autofs-5.1.7.orig/CHANGELOG
de1ab5
+++ autofs-5.1.7/CHANGELOG
de1ab5
@@ -109,6 +109,7 @@
de1ab5
 - coverity fix for invalid access.
de1ab5
 - fix hosts map deadlock on restart.
de1ab5
 - fix deadlock with hosts map reload.
de1ab5
+- fix memory leak in update_hosts_mounts().
de1ab5
 
de1ab5
 25/01/2021 autofs-5.1.7
de1ab5
 - make bind mounts propagation slave by default.
de1ab5
--- autofs-5.1.7.orig/modules/lookup_hosts.c
de1ab5
+++ autofs-5.1.7/modules/lookup_hosts.c
de1ab5
@@ -307,20 +307,21 @@ next:
de1ab5
 	}
de1ab5
 	pthread_cleanup_pop(1);
de1ab5
 
de1ab5
-	while (head) {
de1ab5
+	entries = head;
de1ab5
+	while (entries) {
de1ab5
 		debug(ap->logopt, MODPREFIX
de1ab5
-		      "attempt to update exports for %s", head->key);
de1ab5
+		      "attempt to update exports for %s", entries->key);
de1ab5
 
de1ab5
 		master_source_current_wait(ap->entry);
de1ab5
 		ap->entry->current = source;
de1ab5
 		ap->flags |= MOUNT_FLAG_REMOUNT;
de1ab5
-		ret = ctxt->parse->parse_mount(ap, head->key, strlen(head->key),
de1ab5
-					       head->entry, ctxt->parse->context);
de1ab5
+		ret = ctxt->parse->parse_mount(ap, entries->key, strlen(entries->key),
de1ab5
+					       entries->entry, ctxt->parse->context);
de1ab5
 		if (ret)
de1ab5
 			warn(ap->logopt, MODPREFIX
de1ab5
-			     "failed to parse mount %s", head->entry);
de1ab5
+			     "failed to parse mount %s", entries->entry);
de1ab5
 		ap->flags &= ~MOUNT_FLAG_REMOUNT;
de1ab5
-		head = head->next;
de1ab5
+		entries = entries->next;
de1ab5
 	}
de1ab5
 	pthread_cleanup_pop(1);
de1ab5
 }