From f7f08ba88146f638bf152a7ab3e3016939a819ce Mon Sep 17 00:00:00 2001 From: Peter Rajnoha Date: Mon, 12 Aug 2024 14:16:32 +0200 Subject: [PATCH] libdm: clean up udev sync semaphore on fail path during its creation Clean up udev sync semaphore on fail path during its creation, otherwise the caller will have no handle returned to clean it up itself and the semaphore will keep staying in the system. The only way to clean it up would be to call `dmsetup udevcomplete_all` which would destroy all udev sync semaphores, not just the failed one, which we don't want. --- device_mapper/libdm-common.c | 1 + libdm/libdm-common.c | 1 + 2 files changed, 2 insertions(+) diff --git a/device_mapper/libdm-common.c b/device_mapper/libdm-common.c index eb722c686..db7c75277 100644 --- a/device_mapper/libdm-common.c +++ b/device_mapper/libdm-common.c @@ -2574,6 +2574,7 @@ static int _udev_notify_sem_create(uint32_t *cookie, int *semid) log_error("cookie create: semid %d: sem_ctl GETVAL failed for " "cookie 0x%" PRIx32 ": %s", gen_semid, gen_cookie, strerror(errno)); + (void) _udev_notify_sem_destroy(gen_cookie, gen_semid); goto bad; } diff --git a/libdm/libdm-common.c b/libdm/libdm-common.c index 445b79c17..4054d6cc0 100644 --- a/libdm/libdm-common.c +++ b/libdm/libdm-common.c @@ -2573,6 +2573,7 @@ static int _udev_notify_sem_create(uint32_t *cookie, int *semid) log_error("cookie create: semid %d: sem_ctl GETVAL failed for " "cookie 0x%" PRIx32 ": %s", gen_semid, gen_cookie, strerror(errno)); + (void) _udev_notify_sem_destroy(gen_cookie, gen_semid); goto bad; } -- 2.43.5