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

[lvm-devel] [PATCH 2/4] Fix unlocking for vgrelease for error paths



Signed-off-by: Zdenek Kabelac <zkabelac redhat com>
---
 tools/pvresize.c |    8 ++++++--
 tools/toollib.c  |    6 +++---
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/tools/pvresize.c b/tools/pvresize.c
index 7a911ac..292e3cc 100644
--- a/tools/pvresize.c
+++ b/tools/pvresize.c
@@ -60,8 +60,12 @@ static int _pv_resize_single(struct cmd_context *cmd,
 
 		vg = vg_read_for_update(cmd, vg_name, NULL, 0);
 
-		if (vg_read_error(vg))
-			goto bad;
+		if (vg_read_error(vg)) {
+			vg_release(vg);
+			log_error("Unable to read volume group \"%s\".",
+				  vg_name);
+			return 0;
+		}
 
 		if (!(pvl = find_pv_in_vg(vg, pv_name))) {
 			log_error("Unable to find \"%s\" in volume group \"%s\"",
diff --git a/tools/toollib.c b/tools/toollib.c
index 33daf30..fce399b 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -315,7 +315,7 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
 						  dm_pool_strdup(cmd->mem,
 							      lv_name + 1))) {
 					log_error("strlist allocation failed");
-					vg_release(vg);
+					unlock_and_release_vg(cmd, vg, vgname);
 					return ECMD_FAILED;
 				}
 			}
@@ -367,8 +367,8 @@ int process_each_segment_in_pv(struct cmd_context *cmd,
 		if (!(pvl = find_pv_in_vg(vg, pv_dev_name(pv)))) {
 			 log_error("Unable to find %s in volume group %s",
 				   pv_dev_name(pv), vg_name);
-			vg_release(vg);
-			return ECMD_FAILED;
+			 unlock_and_release_vg(cmd, vg, vg_name);
+			 return ECMD_FAILED;
 		}
 
 		pv = pvl->pv;
-- 
1.6.5.3


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