mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
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().
This commit is contained in:
parent
1d749d01fb
commit
a7ca101517
@ -1,5 +1,6 @@
|
||||
Version 2.02.59 -
|
||||
===================================
|
||||
Cleanup memory initialization and freeing in pv_read() and pv_create().
|
||||
Clear pointer and counters after their release in _fin_commands().
|
||||
Add t-topology-support.sh and t-snapshot-merge.sh tests.
|
||||
Fix clvmd to never scan suspended devices.
|
||||
|
@ -3020,29 +3020,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 */
|
||||
|
Loading…
Reference in New Issue
Block a user