lvmlockd: always free ls struct after ls thread exits
authorDavid Teigland <teigland@redhat.com>
Fri, 5 Sep 2025 17:21:12 +0000 (12:21 -0500)
committerMarian Csontos <mcsontos@redhat.com>
Mon, 29 Sep 2025 16:07:44 +0000 (18:07 +0200)
The ls struct was being freed after ls thread exit for common stop,
but was missing when the ls thread was stopped for drop and rename.
Also free ls->actions structs in case any still exist.

(cherry picked from commit 5b410e589c75d0d540e4ebe4f44cc71b5624cbc6)

daemons/lvmlockd/lvmlockd-core.c

index 369755ac7c04e415b4e8ba6b3aebf8409cd78938..f7340ff3ecb6c1622945d72e377205fd40872660 100644 (file)
@@ -3553,6 +3553,7 @@ static int count_lockspace_starting(uint32_t client_id)
 static int for_each_lockspace(int do_stop, int do_free, int do_force)
 {
        struct lockspace *ls, *safe;
+       struct action *act, *act2;
        int need_stop = 0;
        int need_free = 0;
        int stop_count = 0;
@@ -3605,19 +3606,16 @@ static int for_each_lockspace(int do_stop, int do_free, int do_force)
                                if ((perrno = pthread_join(ls->thread, NULL)))
                                        log_error("pthread_join error %d", perrno);
 
+                               log_debug("free ls struct %s", ls->name);
                                list_del(&ls->list);
-
-                               /* FIXME: will free_vg ever not be set? */
-
-                               log_debug("free ls %s", ls->name);
-
-                               if (ls->free_vg) {
-                                       /* In future we may need to free ls->actions here */
-                                       free_ls_resources(ls);
-                                       free_pvs_path(&ls->pvs);
-                                       free(ls);
-                                       free_count++;
+                               list_for_each_entry_safe(act, act2, &ls->actions, list) {
+                                       list_del(&act->list);
+                                       free_action(act);
                                }
+                               free_ls_resources(ls);
+                               free_pvs_path(&ls->pvs);
+                               free(ls);
+                               free_count++;
                        } else {
                                need_free++;
                        }
This page took 0.076239 seconds and 5 git commands to generate.