swtpm: Check file descriptor >= 0 before closing

Check the file descriptor for >= 0 before closing it. Hopefully
this makes Coverity happy.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
This commit is contained in:
Stefan Berger 2015-05-12 14:09:05 -04:00
parent 9e89ffa12d
commit fddbb58d48

View File

@ -442,8 +442,11 @@ TPM_RESULT SWTPM_IO_Disconnect(TPM_CONNECTION_FD *connection_fd)
TPM_RESULT rc = 0;
/* close the connection to the client */
close(connection_fd->fd);
connection_fd->fd = -1; /* mark the connection closed */
if (connection_fd->fd >= 0) {
close(connection_fd->fd);
connection_fd->fd = -1; /* mark the connection closed */
}
return rc;
}