master - pvcreate: fix leak on error path
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c7c53ad41d5521d5b431e799699c9ad6a07054a4 Commit: c7c53ad41d5521d5b431e799699c9ad6a07054a4 Parent: 0e47639a44e1630250ea10643f5a440281edfdce Author: Zdenek Kabelac <[email protected]> AuthorDate: Thu Oct 18 14:32:56 2012 +0200 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Fri Oct 19 15:32:21 2012 +0200
pvcreate: fix leak on error path
Missing vg release on error path.
Add tests for few more error cases.
--- WHATS_NEW | 1 + test/shell/pvcreate-operation.sh | 11 ++++++++++- tools/pvcreate.c | 1 + 3 files changed, 12 insertions(+), 1 deletions(-)
WHATS_NEW +1 -0
@@ -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.
test/shell/pvcreate-operation.sh +10 -1
@@ -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"
tools/pvcreate.c +1 -0
@@ -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 ;