diff --git a/WHATS_NEW b/WHATS_NEW index 8ba9f2d82..ad0756a1d 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -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. diff --git a/test/shell/pvcreate-operation.sh b/test/shell/pvcreate-operation.sh index 55fff4e8d..ddcf94cd5 100644 --- a/test/shell/pvcreate-operation.sh +++ b/test/shell/pvcreate-operation.sh @@ -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" diff --git a/tools/pvcreate.c b/tools/pvcreate.c index 5c12acbc1..c75f5619b 100644 --- a/tools/pvcreate.c +++ b/tools/pvcreate.c @@ -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;