Skip to contentSkip to conversation

Fix memory leak in lv_info_by_lvid

PATCH New Milan Broz 1 participant 1 message Dec 1, 2009

lore
Share & tools
lore

Milan Broz

author
#0 lore raw

PATCH 1/1 Fix memory leak in lv_info_by_lvid

The lv_from_lvid calls internally vg_read(),
we myst relelase vg structure afterwards.

Code is called only from clvmd.

---
 lib/activate/activate.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
lib/activate/activate.c +5 -1
index b3a70db..1aaa16c 100644
@@ -486,12 +486,16 @@ int lv_info(struct cmd_context *cmd, const struct logical_volume *lv, struct lvi
 int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s,
 		    struct lvinfo *info, int with_open_count, int with_read_ahead)
 {
+	int r;
 	struct logical_volume *lv;
 
 	if (!(lv = lv_from_lvid(cmd, lvid_s, 0)))
 		return 0;
 
-	return _lv_info(cmd, lv, 0, info, with_open_count, with_read_ahead, 0);
+	r = _lv_info(cmd, lv, 0, info, with_open_count, with_read_ahead, 0);
+	vg_release(lv->vg);
+
+	return r;
 }
 
 /*
Signature · 1 line
1.6.5.3