lvmlockd: fix missing free in vg_status
authorDavid Teigland <teigland@redhat.com>
Thu, 26 Jun 2025 18:42:38 +0000 (13:42 -0500)
committerMarian Csontos <mcsontos@redhat.com>
Mon, 29 Sep 2025 16:07:44 +0000 (18:07 +0200)
and add more checking of get_hosts result.

used by lockd_vg_is_started() for the PR feature.

(cherry picked from commit 5f0ddd0fd891e769577f6cd3546326f18dbc3bca)

daemons/lvmlockd/lvmlockd-sanlock.c

index 1af3c368fde449b4c6653ce58c584cd325b1ef24..97f06d115b2ddce21b2e0cc4b758877b947dd5d0 100644 (file)
@@ -2352,7 +2352,7 @@ int lm_unlock_sanlock(struct lockspace *ls, struct resource *r,
 
 int lm_vg_status_sanlock(struct lockspace *ls, struct action *act)
 {
-       struct sanlk_host *hs;
+       struct sanlk_host *hs = NULL;
        const char *host_state;
        int count = 0;
        int rv;
@@ -2366,6 +2366,11 @@ int lm_vg_status_sanlock(struct lockspace *ls, struct action *act)
                return rv;
        }
 
+       if (!count || !hs) {
+               log_error("S %s vg_status_san get_hosts empty", ls->name);
+               return -EINVAL;
+       }
+
        act->owner.host_id = (uint32_t)hs->host_id;
        act->owner.generation = (uint32_t)hs->generation;
        act->owner.timestamp = (uint32_t)hs->timestamp;
@@ -2373,6 +2378,7 @@ int lm_vg_status_sanlock(struct lockspace *ls, struct action *act)
        if ((host_state = _host_flags_to_str(hs->flags)))
                dm_strncpy(act->owner.state, host_state, OWNER_STATE_SIZE-1);
 
+       free(hs);
        return 0;
 }
 
This page took 0.093909 seconds and 5 git commands to generate.