swtpm_ioctl: Close file descriptor at end of main (Coverity)
Close the file descriptor at the end of the main function.
To avoid closing random file descriptors initialize it with -1.
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
diff --git a/src/swtpm_ioctl/tpm_ioctl.c b/src/swtpm_ioctl/tpm_ioctl.c
index 2dc8ea4..16c668b 100644
--- a/src/swtpm_ioctl/tpm_ioctl.c
+++ b/src/swtpm_ioctl/tpm_ioctl.c
@@ -907,7 +907,7 @@
int main(int argc, char *argv[])
{
- int fd, n;
+ int fd = -1, n;
ptm_est est;
ptm_reset_est reset_est;
ptm_loc loc;
@@ -1315,5 +1315,7 @@
exit:
free(tcp_hostname);
+ close(fd);
+
return ret;
}