From 54840d867e5aaaf64777ebc19374f1fdd72a9bcb Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 11 Apr 2024 23:19:20 +0200 Subject: [PATCH] devmapper-event: add unlock into init_fifo error path Unlock server path if there is open failure for client_path and whole init_fifos() function is returning failure. --- daemons/dmeventd/libdevmapper-event.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/daemons/dmeventd/libdevmapper-event.c b/daemons/dmeventd/libdevmapper-event.c index 12e3b53c5..c60781250 100644 --- a/daemons/dmeventd/libdevmapper-event.c +++ b/daemons/dmeventd/libdevmapper-event.c @@ -513,7 +513,7 @@ int init_fifos(struct dm_event_fifos *fifos) /* Lock out anyone else trying to do communication with the daemon. */ if (flock(fifos->server, LOCK_EX) < 0) { log_sys_error("flock", fifos->server_path); - goto bad; + goto bad_no_unlock; } /* if ((fifos->client = open(fifos->client_path, O_WRONLY | O_NONBLOCK)) < 0) {*/ @@ -524,6 +524,9 @@ int init_fifos(struct dm_event_fifos *fifos) return 1; bad: + if (flock(fifos->server, LOCK_UN)) + log_sys_debug("flock unlock", fifos->server_path); +bad_no_unlock: if (close(fifos->server)) log_sys_debug("close", fifos->server_path); fifos->server = -1;