Skip to contentSkip to conversation

master - lvmcache: fix loop freeing infos

PATCH David Teigland 1 participant 1 message May 14, 2018

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=11ceb77867560e0b804df5ec3162e9cbdc9ed321
Commit:        11ceb77867560e0b804df5ec3162e9cbdc9ed321
Parent:        517d6cc418da0ba08a971b6d537cdfada7a5b1cb
Author:        David Teigland <[email protected]>
AuthorDate:    Mon May 14 13:45:55 2018 -0500
Committer:     David Teigland <[email protected]>
CommitterDate: Mon May 14 13:45:55 2018 -0500

lvmcache: fix loop freeing infos

valgrind was concerned about loop through vginfo->infos, so grab info from dev.

---
 lib/cache/lvmcache.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
lib/cache/lvmcache.c +4 -4
index 12c1c99..9912995 100644
@@ -1310,7 +1310,7 @@ int lvmcache_label_rescan_vg(struct cmd_context *cmd, const char *vgname, const
 	struct dm_list devs;
 	struct device_list *devl, *devl2;
 	struct lvmcache_vginfo *vginfo;
-	struct lvmcache_info *info, *info2;
+	struct lvmcache_info *info;
 
 	if (lvmetad_used())
 		return 1;
@@ -1339,9 +1339,9 @@ int lvmcache_label_rescan_vg(struct cmd_context *cmd, const char *vgname, const
 		dm_list_add(&devs, &devl->list);
 	}
 
-	/* Deleting the last info will delete vginfo. */
-	dm_list_iterate_items_safe(info, info2, &vginfo->infos)
-		lvmcache_del(info);
+	/* Delete info for each dev, deleting the last info will delete vginfo. */
+	dm_list_iterate_items(devl, &devs)
+		lvmcache_del_dev(devl->dev);
 
 	/* Dropping the last info struct is supposed to drop vginfo. */
 	if ((vginfo = lvmcache_vginfo_from_vgname(vgname, vgid)))