1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

pvcreate: fix leak on error path

Missing vg release on error path.
Add tests for few more error cases.
This commit is contained in:
Zdenek Kabelac 2012-10-18 14:32:56 +02:00
parent 0e47639a44
commit c7c53ad41d
3 changed files with 12 additions and 1 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
Fix memory leak on error path for pvcreate with invalid uuid.
Use lv_is_active() instead of lv_info() call.
Cleanup some log_error message and use log_warn instead.

View File

@ -1,4 +1,4 @@
# Copyright (C) 2008 Red Hat, Inc. All rights reserved.
# Copyright (C) 2008-2012 Red Hat, Inc. All rights reserved.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
@ -121,6 +121,15 @@ vgcfgrestore -f $backupfile $vg1
vgremove -f $vg1
pvremove -f $dev1
# pvcreate rejects non-existent uuid given with restorefile
not pvcreate --uuid $uuid1 --restorefile $backupfile "$dev1"
# pvcreate rejects restorefile without uuid
not pvcreate --restorefile $backupfile "$dev1"
# pvcreate rejects uuid restore with multiple volumes specified
not pvcreate --uuid $uuid1 --restorefile $backupfile "$dev1" "$dev2"
# pvcreate wipes swap signature when forced
dd if=/dev/zero of="$dev1" bs=1024 count=64
mkswap "$dev1"

View File

@ -68,6 +68,7 @@ static int pvcreate_restore_params_validate(struct cmd_context *cmd,
return 0;
}
if (!(existing_pvl = find_pv_in_vg_by_uuid(vg, pp->idp))) {
release_vg(vg);
log_error("Can't find uuid %s in backup file %s",
uuid, pp->restorefile);
return 0;