Skip to contentSkip to conversation

Coverity fixes for xenconsole

PATCH In review Andrew Cooper 2 participants 5 messages Nov 25, 2013

lore
Share & tools
lore
#1 lore raw

PATCH 1/2 tools/xenconsole: Use xc_domain_getinfo() correctly

Coverity ID: 1055018

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
---
 tools/console/client/main.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/console/client/main.c +5 -1
index 523fc23..38c856a 100644
@@ -339,7 +339,11 @@ int main(int argc, char **argv)
 		xc_interface *xc_handle = xc_interface_open(0,0,0);
 		if (xc_handle == NULL)
 			err(errno, "Could not open xc interface");
-		xc_domain_getinfo(xc_handle, domid, 1, &xcinfo);
+		if ( (xc_domain_getinfo(xc_handle, domid, 1, &xcinfo) != 1) ||
+		     (xcinfo.domid != domid) ) {
+			xc_interface_close(xc_handle);
+			err(errno, "Failed to get domain information");
+		}
 		/* default to pv console for pv guests and serial for hvm guests */
 		if (xcinfo.hvm)
 			type = CONSOLE_SERIAL;
Signature · 1 line
1.7.10.4
#3 lore raw

PATCH 2/2 tools/xenconsoled: Fix file handle leaks

In reply to Andrew Cooper

Coverity ID: 715218 1055876 1055877

CC Ian Campbell <[email protected]>
CC Ian Jackson <[email protected]>
---
 tools/console/daemon/io.c    |    2 ++
 tools/console/daemon/utils.c |    1 +
 2 files changed, 3 insertions(+)
tools/console/daemon/io.c +2 -0
index 250550a..007ecf4 100644
@@ -278,6 +278,7 @@ static int create_hv_log(void)
 			dolog(LOG_ERR, "Failed to log opening timestamp "
 				       "in %s: %d (%s)", logfile, errno,
 				       strerror(errno));
+			close(fd);
 			return -1;
 		}
 	}
@@ -323,6 +324,7 @@ static int create_domain_log(struct domain *dom)
 			dolog(LOG_ERR, "Failed to log opening timestamp "
 				       "in %s: %d (%s)", logfile, errno,
 				       strerror(errno));
+			close(fd);
 			return -1;
 		}
 	}
tools/console/daemon/utils.c +1 -0
index aab6f42..71dd185 100644
@@ -104,6 +104,7 @@ void daemonize(const char *pidfile)
 	signal(SIGTSTP, SIG_IGN);
 	signal(SIGTTOU, SIG_IGN);
 	signal(SIGTTIN, SIG_IGN);
+	close(fd);
 }
 
 bool xen_setup(void)
Signature · 1 line
1.7.10.4