[Spice-devel] [PATCH linux vdagent 2/2] Avoid leaking udscs file descriptor

Jonathon Jongsma jjongsma at redhat.com
Wed Nov 29 16:44:46 UTC 2017


This is a  finding from coverity. In practice it has very little impact
since returning NULL from this function results in the process existing
with an error.

Signed-off-by: Jonathon Jongsma <jjongsma at redhat.com>
---
 src/udscs.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/udscs.c b/src/udscs.c
index 64f0307..6e73015 100644
--- a/src/udscs.c
+++ b/src/udscs.c
@@ -450,12 +450,14 @@ struct udscs_server *udscs_create_server(const char *socketname,
     c = bind(fd, (struct sockaddr *)&address, sizeof(address));
     if (c != 0) {
         syslog(LOG_ERR, "bind %s: %m", socketname);
+        close(fd);
         return NULL;
     }
 
     c = listen(fd, 5);
     if (c != 0) {
         syslog(LOG_ERR, "listen: %m");
+        close(fd);
         return NULL;
     }
 
-- 
2.13.6



More information about the Spice-devel mailing list