From 3ac89d45f3b5091fa3864248a50a4d15ebacb6d9 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 13 Mar 2019 22:51:19 +0800 Subject: [PATCH 19/19] cov: ensure lock_type is not NULL --- tools/vgchange.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/vgchange.c b/tools/vgchange.c index 623517b..40c3c4d 100644 --- a/tools/vgchange.c +++ b/tools/vgchange.c @@ -932,7 +932,7 @@ static int _vgchange_locktype(struct cmd_context *cmd, struct volume_group *vg) int lv_lock_count = 0; /* Special recovery case. */ - if (lockopt && !strcmp(lock_type, "none") && !strcmp(lockopt, "force")) { + if (lock_type && lockopt && !strcmp(lock_type, "none") && !strcmp(lockopt, "force")) { vg->status &= ~CLUSTERED; vg->lock_type = "none"; vg->lock_args = NULL; @@ -997,7 +997,7 @@ static int _vgchange_locktype(struct cmd_context *cmd, struct volume_group *vg) } /* none to clvm */ - if (!strcmp(vg->lock_type, "none") && !strcmp(lock_type, "clvm")) { + if (lock_type && !strcmp(vg->lock_type, "none") && !strcmp(lock_type, "clvm")) { log_warn("New clvm lock type will not be usable with lvmlockd."); vg->status |= CLUSTERED; vg->lock_type = "clvm"; /* this is optional */ @@ -1110,7 +1110,7 @@ static int _vgchange_locktype(struct cmd_context *cmd, struct volume_group *vg) } /* ... to none */ - if (!strcmp(lock_type, "none")) { + if (lock_type && !strcmp(lock_type, "none")) { vg->lock_type = NULL; vg->system_id = cmd->system_id ? dm_pool_strdup(vg->vgmem, cmd->system_id) : NULL; return 1; -- 2.19.1