Skip to contentSkip to conversation

endless loop in _free_vginfo

PATCH James M Leddy 2 participants 2 messages Mar 10, 2011

lore
Share & tools
lore
#0 lore raw

Concerning the _free_vginfo function field in cache/lvmcache.c. It looks like this code is supposed to traverse a list (list of vgs with the same name?), but the assignment is the same on every iteration. cache/lvmcache.c: 809

	if (vginfo == primary_vginfo) {
		dm_hash_remove(_vgname_hash, vginfo->vgname);
		if (vginfo->next && !dm_hash_insert(_vgname_hash, vginfo->vgname,
						    vginfo->next)) {
			log_error("_vgname_hash re-insertion for %s failed",
				  vginfo->vgname);
			r = 0;
		}
	} else do
		if (vginfo2->next == vginfo) {
			vginfo2->next = vginfo->next;
			break;
		}

while ((vginfo2 = primary_vginfo->next));

Shouldn't it be this ?

tmp/buffer-content-2482n5q renamed from home/james/rpmbuild/lvm2/2.02.72-8.fc14.4/work/LVM2.2.02.72/lib/cache/lvmcache.c +1 -1
diff -c /home/james/rpmbuild/lvm2/2.02.72-8.fc14.4/work/LVM2.2.02.72/lib/cache/lvmcache.c /tmp/buffer-content-2482n5q
@@ -819,7 +819,7 @@
 			vginfo2->next = vginfo->next;
 			break;
 		}
- 	while ((vginfo2 = primary_vginfo->next));
+ 	while ((vginfo2 = vginfo2->next));
 
 	if (vginfo->vgname)
 		dm_free(vginfo->vgname);

We ran into this when we have duplicate PV, probably also have a duplicate VG if that is what exposes this bug.

Signature · 3 lines
James M. Leddy
Technical Account Manager
Red Hat Inc.
#1 lore raw

tmp/buffer-content-2482n5q line 822

Quoted 5 lines · James M Leddy

[...]
Shouldn't it be this ?

tmp/buffer-content-2482n5q renamed from home/james/rpmbuild/lvm2/2.02.72-8.fc14.4/work/LVM2.2.02.72/lib/cache/lvmcache.c +1 -1
- 	while ((vginfo2 = primary_vginfo->next));
+ 	while ((vginfo2 = vginfo2->next));

Isn't that whole loop then equivalent to "vginfo2 = NULL;" ?

- FChE