From: Sage Weil Date: Sat, 29 Sep 2012 01:14:24 +0000 (-0700) Subject: filstore: fix leak of fd in write error paths X-Git-Tag: v0.54~180 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f4c34c06e9df688c8a12395e46dfff7e970aa6bb;p=ceph.git filstore: fix leak of fd in write error paths CID 717095: Resource leak (RESOURCE_LEAK) At (13): Handle variable "fd" going out of scope leaks the handle. Signed-off-by: Sage Weil --- diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index 2c5e33d28117..b4e3018ebc58 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -3208,11 +3208,13 @@ int FileStore::_write(coll_t cid, const hobject_t& oid, if (actual < 0) { r = -errno; dout(0) << "write lseek64 to " << offset << " failed: " << cpp_strerror(r) << dendl; + TEMP_FAILURE_RETRY(::close(fd)); goto out; } if (actual != (int64_t)offset) { dout(0) << "write lseek64 to " << offset << " gave bad offset " << actual << dendl; r = -EIO; + TEMP_FAILURE_RETRY(::close(fd)); goto out; }