From ae8ba49142e452d2459230fcb98ffd39ec62e12a Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Wed, 30 Oct 2024 11:54:42 +0100 Subject: [PATCH] cov: validate string with lock mode Check the dev_mode string is not NULL before use. --- lib/locking/lvmlockd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c index 58d24d4bb..d92c37087 100644 --- a/lib/locking/lvmlockd.c +++ b/lib/locking/lvmlockd.c @@ -2905,7 +2905,7 @@ int lockd_lv(struct cmd_context *cmd, struct logical_volume *lv, return 0; } - if (!_lvmlockd_connected && !strcmp(def_mode, "un")) { + if (!_lvmlockd_connected && (def_mode && !strcmp(def_mode, "un"))) { log_debug("Skip LV unlock: no lvmlockd"); return 1; } @@ -2922,7 +2922,7 @@ int lockd_lv(struct cmd_context *cmd, struct logical_volume *lv, * The command still attempts to deactivate the LVs, * which it should in case they are active for some reason. */ - if (lv->vg->lockd_not_started && !strcmp(def_mode, "un")) { + if (lv->vg->lockd_not_started && (def_mode && !strcmp(def_mode, "un"))) { log_debug("Skip LV unlock: no lockspace"); return 1; }