[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[lvm-devel] [PATCH 3/3] Call _alloc_pv() inside _pv_read() and clean up error paths.



We should be consistent with pv constructors so call _alloc_pv()
here as we do from pv_create().

Signed-off-by: Dave Wysochanski <dwysocha redhat com>
---
 lib/metadata/metadata.c |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index a03194e..054d716 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -3021,29 +3021,30 @@ static struct physical_volume *_pv_read(struct cmd_context *cmd,
 	if (label_sector && *label_sector)
 		*label_sector = label->sector;
 
-	if (!(pv = dm_pool_zalloc(pvmem, sizeof(*pv)))) {
+	pv = _alloc_pv(pvmem, dev);
+	if (!pv) {
 		log_error("pv allocation for '%s' failed", pv_name);
 		return NULL;
 	}
 
-	dm_list_init(&pv->tags);
-	dm_list_init(&pv->segments);
-
 	/* FIXME Move more common code up here */
 	if (!(info->fmt->ops->pv_read(info->fmt, pv_name, pv, mdas,
 	      scan_label_only))) {
 		log_error("Failed to read existing physical volume '%s'",
 			  pv_name);
-		return NULL;
+		goto bad;
 	}
 
 	if (!pv->size)
-		return NULL;
+		goto bad;
 
 	if (!alloc_pv_segment_whole_pv(pvmem, pv))
-		return_NULL;
+		goto_bad;
 
 	return pv;
+bad:
+	_free_pv(pvmem, pv);
+	return NULL;
 }
 
 /* May return empty list */
-- 
1.6.0.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]