From 486b15d36ce672f78a35143ce6bb12c48552fbf8 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Thu, 20 Mar 2014 13:53:39 +0100 Subject: [PATCH] memlock: drop locked mem in critical section When daemon releases memory and it is still in critical section, issue an error message and drop memory. We cannot do anything better for now and we at least release allocated resource. FIXME: This code is triggered when i.e. clvmd is killed while some LVs are suspend - in this case suspended devices leak, so if this happens during i.e. clvmd upgrade we have unresolved problem - even locked rootfs... --- lib/mm/memlock.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/mm/memlock.c b/lib/mm/memlock.c index f32424a24..a83c3ed17 100644 --- a/lib/mm/memlock.c +++ b/lib/mm/memlock.c @@ -456,6 +456,11 @@ void memlock_dec_daemon(struct cmd_context *cmd) log_error(INTERNAL_ERROR "_memlock_count_daemon has dropped below 0."); --_memlock_count_daemon; log_debug_mem("memlock_count_daemon dec to %d", _memlock_count_daemon); + if (!_memlock_count_daemon && _critical_section && _mem_locked) { + log_error("Unlocking daemon memory in critical section."); + _unlock_mem(cmd); + _mem_locked = 0; + } _unlock_mem_if_possible(cmd); }