From b1d80a0ffdde6d6ea94a85a93d8f67fe0ea929f8 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Sun, 16 Jun 2024 15:15:44 +0200 Subject: [PATCH] gcc: pipe error path Close opened descriptors on failed fork path. --- lib/misc/lvm-exec.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/misc/lvm-exec.c b/lib/misc/lvm-exec.c index 172c0fa4a..203e2dff4 100644 --- a/lib/misc/lvm-exec.c +++ b/lib/misc/lvm-exec.c @@ -164,7 +164,11 @@ FILE *pipe_open(struct cmd_context *cmd, const char *const argv[], log_verbose("Piping:%s", _verbose_args(argv, buf, sizeof(buf))); if ((pdata->pid = fork()) == -1) { - log_sys_error("pipe", ""); + log_sys_error("fork", ""); + if (close(pipefd[0])) + log_sys_debug("close", "STDOUT"); + if (close(pipefd[1])) + log_sys_debug("close", "STDIN"); return 0; }