From 80b7fe0e883985bee6d57e53de2af68dc727289b Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Mon, 9 Jun 2008 16:22:33 +0000 Subject: [PATCH] Fix segfault after _free_vginfo by remembering to remove vginfo from list. --- WHATS_NEW | 1 + lib/cache/lvmcache.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index 597192b50..e5adfcc80 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.38 - ================================= + Fix segfault after _free_vginfo by remembering to remove vginfo from list. Tweak detection of invalid fid after changes to PVs in VG in _vg_read. Revert assuming precommitted metadata is live when activating (unnecessary). Drop cached metadata for disappearing VG in vgmerge. diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c index 4d152cf0d..d232f6772 100644 --- a/lib/cache/lvmcache.c +++ b/lib/cache/lvmcache.c @@ -631,11 +631,14 @@ struct device *device_from_pvid(struct cmd_context *cmd, struct id *pvid) static int _free_vginfo(struct lvmcache_vginfo *vginfo) { + struct lvmcache_vginfo *primary_vginfo, *vginfo2; int r = 1; _free_cached_vgmetadata(vginfo); - if (vginfo_from_vgname(vginfo->vgname, NULL) == vginfo) { + vginfo2 = primary_vginfo = vginfo_from_vgname(vginfo->vgname, NULL); + + if (vginfo == primary_vginfo) { dm_hash_remove(_vgname_hash, vginfo->vgname); if (vginfo->next && !dm_hash_insert(_vgname_hash, vginfo->vgname, vginfo->next)) { @@ -643,7 +646,12 @@ static int _free_vginfo(struct lvmcache_vginfo *vginfo) vginfo->vgname); r = 0; } - } + } else do + if (vginfo2->next == vginfo) { + vginfo2->next = vginfo->next; + break; + } + while ((vginfo2 = primary_vginfo->next)); if (vginfo->vgname) dm_free(vginfo->vgname);