[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] lxc: detect socket failure



Coverity warned about a potential close(-1).

* src/lxc/lxc_controller.c (lxcControllerMain): React to failure
to accept.
---
 src/lxc/lxc_controller.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index 95970cc..318106e 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -1,5 +1,6 @@
 /*
+ * Copyright (C) 2010 Red Hat, Inc.
  * Copyright IBM Corp. 2008
  *
  * lxc_controller.c: linux container process controller
  *
@@ -348,8 +349,13 @@ static int lxcControllerMain(int monitor,
         numEvents = epoll_wait(epollFd, &epollEvent, 1, timeout);
         if (numEvents > 0) {
             if (epollEvent.data.fd == monitor) {
                 int fd = accept(monitor, NULL, 0);
+                if (fd < 0) {
+                    virReportSystemError(errno, "%s",
+                                         _("epoll_ctl(client) failed"));
+                    goto cleanup;
+                }
                 if (client != -1) { /* Already connected, so kick new one out */
                     close(fd);
                     continue;
                 }
-- 
1.6.6.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]