From: Sage Weil Date: Fri, 28 Dec 2012 23:14:25 +0000 (-0800) Subject: client: fix fh leak in non-create case X-Git-Tag: v0.57~265^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3debf0cf3da5e2528a7609f962132e450f509510;p=ceph.git client: fix fh leak in non-create case We may take the O_CREAT path and get an fh from _create, but created can still be false. In that case, skip the final _open call. Signed-off-by: Sage Weil --- diff --git a/src/client/Client.cc b/src/client/Client.cc index c066a2bd90c5..aaa1c1614a45 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -7169,6 +7169,8 @@ int Client::ll_create(vinodeno_t parent, const char *name, mode_t mode, int flag tout(cct) << mode << std::endl; tout(cct) << flags << std::endl; + *fhp = NULL; + bool created = false; Inode *in = NULL; Inode *dir = _ll_get_inode(parent); @@ -7199,9 +7201,11 @@ int Client::ll_create(vinodeno_t parent, const char *name, mode_t mode, int flag if (r < 0) goto out; - r = _open(in, flags, mode, fhp); - if (r < 0) - goto out; + if (*fhp == NULL) { + r = _open(in, flags, mode, fhp); + if (r < 0) + goto out; + } } out: