sanlock: fix file descriptor leak in error path
authorZdenek Kabelac <zkabelac@redhat.com>
Thu, 10 Jul 2025 13:13:18 +0000 (15:13 +0200)
committerMarian Csontos <mcsontos@redhat.com>
Mon, 29 Sep 2025 16:07:45 +0000 (18:07 +0200)
Add proper cleanup of file descriptor in the error handling path
to prevent resource leaks when sanlock operations fail.

(cherry picked from commit f82c46e6735ce123da27fb576371e660697b0bb7)

daemons/lvmlockd/lvmlockd-sanlock.c

index 93cb3ab17a8a479f5bae4780205662e8c6dd63cc..17820b91d23c7665927d5e7503b38fcf53e51809 100644 (file)
@@ -320,8 +320,11 @@ static int read_host_id_file(void)
                        break;
                }
        }
-       _fclose(file, (char *)daemon_host_id_file);
+
 out:
+       if (file)
+               _fclose(file, (char *)daemon_host_id_file);
+
        log_debug("host_id %d from %s", host_id, daemon_host_id_file);
        return host_id;
 }
This page took 0.084297 seconds and 5 git commands to generate.