From 7e9fbf55184a80e866d22e3062e93ba4b703113a Mon Sep 17 00:00:00 2001 From: Petr Rockai Date: Sun, 26 Feb 2012 13:42:50 +0000 Subject: [PATCH] Fix a possible SEGV in lvmetad client code, and a minor leak in pvscan --lvmetad. --- lib/cache/lvmetad.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c index 00da75d77..6d34382eb 100644 --- a/lib/cache/lvmetad.c +++ b/lib/cache/lvmetad.c @@ -566,9 +566,10 @@ static int _pvscan_lvmetad_single(struct metadata_area *mda, void *baton) { struct _pvscan_lvmetad_baton *b = baton; struct volume_group *this = mda->ops->vg_read(b->fid, "", mda); - if ((this && !b->vg) || this->seqno > b->vg->seqno) + if (!b->vg || this->seqno > b->vg->seqno) b->vg = this; - else release_vg(this); + else if (b->vg) + release_vg(this); return 1; } @@ -647,6 +648,8 @@ int pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv) &fic); lvmcache_foreach_mda(info, _pvscan_lvmetad_single, &baton); + if (!baton.vg) + lvmcache_fmt(info)->ops->destroy_instance(baton.fid); /* * NB. If this command failed and we are relying on lvmetad to have an