sanlock: fix file descriptor leak in error path
authorZdenek Kabelac <zkabelac@redhat.com>
Thu, 10 Jul 2025 13:13:18 +0000 (15:13 +0200)
committerZdenek Kabelac <zkabelac@redhat.com>
Sun, 13 Jul 2025 15:16:20 +0000 (17:16 +0200)
Add proper cleanup of file descriptor in the error handling path
to prevent resource leaks when sanlock operations fail.

daemons/lvmlockd/lvmlockd-sanlock.c

index 48ed75d442bcbfbd6c2b5b4eabfc1391a6f4de88..aac47090f8dcee53d08d5d886ca54f12623258d1 100644 (file)
@@ -323,8 +323,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.081487 seconds and 5 git commands to generate.