From fddbb58d4802e5c4f465f41e73640a8a957776b8 Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Tue, 12 May 2015 14:09:05 -0400 Subject: [PATCH] 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 --- src/swtpm/swtpm_io.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/swtpm/swtpm_io.c b/src/swtpm/swtpm_io.c index a8c7827..a5f9905 100644 --- a/src/swtpm/swtpm_io.c +++ b/src/swtpm/swtpm_io.c @@ -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; }