mirror of
https://github.com/stefanberger/swtpm.git
synced 2026-08-10 11:10:51 +00:00
swtpm: Unconditionally close fd if writing of pidfile fails (coverity)
Do not bother trying to keep pidfilefd open in case fd = pidfilefd, but close it unconditionally. If writing the pidfile fails, the process terminates anyway, besides that we only ever need to write to the pidfile once, which is happening in this function. Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
parent
2cb9f95680
commit
1dbde0a148
@ -91,6 +91,8 @@ int pidfile_write(pid_t pid)
|
||||
g_pidfile = fd_to_filename(pidfilefd);
|
||||
if (!g_pidfile)
|
||||
goto error;
|
||||
|
||||
pidfile_set_fd(-1); /* will be closed */
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
@ -118,8 +120,7 @@ int pidfile_write(pid_t pid)
|
||||
return 0;
|
||||
|
||||
error_close:
|
||||
if (fd != pidfilefd)
|
||||
close(fd);
|
||||
close(fd);
|
||||
|
||||
error:
|
||||
return -1;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user