On error, the @pidfilefd was not released

Found by Coverity

Signed-off-by: John Ferlan <jfer...@redhat.com>
---
 src/util/vircommand.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/util/vircommand.c b/src/util/vircommand.c
index e47dd6b932..1716225aeb 100644
--- a/src/util/vircommand.c
+++ b/src/util/vircommand.c
@@ -792,12 +792,14 @@ virExec(virCommandPtr cmd)
         if (virSetInherit(pidfilefd, true) < 0) {
             virReportSystemError(errno, "%s",
                                  _("Cannot disable close-on-exec flag"));
+            virPidFileReleasePath(cmd->pidfile, pidfilefd);
             goto fork_error;
         }
 
         c = '1';
         if (safewrite(pipesync[1], &c, sizeof(c)) != sizeof(c)) {
             virReportSystemError(errno, "%s", _("Unable to notify child 
process"));
+            virPidFileReleasePath(cmd->pidfile, pidfilefd);
             goto fork_error;
         }
         VIR_FORCE_CLOSE(pipesync[0]);
-- 
2.28.0

Reply via email to