From 8716d8c1886fb459c25f8adf69a671f0941bade4 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 25 Mar 2024 14:33:40 +0100 Subject: [PATCH] cov: check for to_dlm_mode return value Avoid processing invalid to_dlm_mode in lm_convert_dlm. --- daemons/lvmlockd/lvmlockd-dlm.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/daemons/lvmlockd/lvmlockd-dlm.c b/daemons/lvmlockd/lvmlockd-dlm.c index 52a293abb..528fe7aa9 100644 --- a/daemons/lvmlockd/lvmlockd-dlm.c +++ b/daemons/lvmlockd/lvmlockd-dlm.c @@ -637,7 +637,7 @@ int lm_convert_dlm(struct lockspace *ls, struct resource *r, struct lm_dlm *lmd = (struct lm_dlm *)ls->lm_data; struct rd_dlm *rdd = (struct rd_dlm *)r->lm_data; struct dlm_lksb *lksb = &rdd->lksb; - uint32_t mode; + int mode; uint32_t flags = 0; int rv; @@ -661,8 +661,10 @@ int lm_convert_dlm(struct lockspace *ls, struct resource *r, flags |= LKF_VALBLK; } - mode = to_dlm_mode(ld_mode); - + if ((mode = to_dlm_mode(ld_mode)) < 0) { + log_error("lm_convert_dlm invalid mode %d", ld_mode); + return -EINVAL; + } if (daemon_test) return 0;