]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
adminsocket: fix sock-fd leak in failure path
authorSage Weil <sage@inktank.com>
Fri, 28 Sep 2012 13:48:11 +0000 (06:48 -0700)
committerSage Weil <sage@inktank.com>
Fri, 28 Sep 2012 20:18:04 +0000 (13:18 -0700)
CID 728088: Resource leak (RESOURCE_LEAK)
At (9): Handle variable "sock_fd" going out of scope leaks the handle.

Signed-off-by: Sage Weil <sage@inktank.com>
src/common/admin_socket.cc

index 63974eba59a86434ab90861e17d49d2f07fa299d..a321dc3c7343b45710e3b0c0332a029f7482ae3f 100644 (file)
@@ -168,6 +168,7 @@ std::string AdminSocket::bind_and_listen(const std::string &sock_path, int *fd)
   int r = fcntl(sock_fd, F_SETFD, FD_CLOEXEC);
   if (r < 0) {
     r = errno;
+    TEMP_FAILURE_RETRY(::close(sock_fd));
     ostringstream oss;
     oss << "AdminSocket::bind_and_listen: failed to fcntl on socket: " << cpp_strerror(r);
     return oss.str();