From: Samuel Just Date: Tue, 25 Sep 2012 22:15:58 +0000 (-0700) Subject: FileStore: fix filedescriptor leak in mkfs X-Git-Tag: v0.53~41^2~7 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=620701df498d16ccb63cd7c07059ee44e28a05a1;p=ceph.git FileStore: fix filedescriptor leak in mkfs CID 717091: Resource leak (RESOURCE_LEAK)At (39): Handle variable "fd" going out of scope leaks the handle. Signed-off-by: Samuel Just --- diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index 9e8d0501c6dbc..0ff995dfb05c7 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -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: "