]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
FileStore: fix filedescriptor leak in mkfs
authorSamuel Just <sam.just@inktank.com>
Tue, 25 Sep 2012 22:15:58 +0000 (15:15 -0700)
committerSamuel Just <sam.just@inktank.com>
Wed, 26 Sep 2012 17:16:24 +0000 (10:16 -0700)
CID 717091: Resource leak (RESOURCE_LEAK)At (39): Handle variable "fd" going
out of scope leaks the handle.

Signed-off-by: Samuel Just <sam.just@inktank.com>
src/os/FileStore.cc

index 9e8d0501c6dbc4200c103fd6842757c0aa1c1425..0ff995dfb05c73a1a3927311c4aded7d16ea5311 100644 (file)
@@ -1106,12 +1106,15 @@ int FileStore::mkfs()
        if (::ioctl(basedir_fd, BTRFS_IOC_SNAP_CREATE, (unsigned long int)&volargs)) {
          ret = -errno;
          if (ret != -EEXIST) {
+           TEMP_FAILURE_RETRY(::close(fd));  
+           TEMP_FAILURE_RETRY(::close(volargs.fd));
            derr << "mkfs: failed to create " << volargs.name << ": "
                 << cpp_strerror(ret) << dendl;
            goto close_fsid_fd;
          }
        }
        if (::fchmod(volargs.fd, 0755)) {
+         TEMP_FAILURE_RETRY(::close(fd));  
          TEMP_FAILURE_RETRY(::close(volargs.fd));
          ret = -errno;
          derr << "mkfs: failed to chmod " << basedir << "/" << volargs.name << " to 0755: "