From 93d69dd77f10b901cd0c7b713bf71acb365e5271 Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Tue, 14 Feb 2023 19:35:14 +0800 Subject: [PATCH] client: fix CEPH_CAP_FILE_WR caps reference leakage in _write() If the __setattrx() fails it will leave the CEPH_CAP_FILE_WR caps reference kept. Fixes: https://tracker.ceph.com/issues/58717 Signed-off-by: Xiubo Li --- src/client/Client.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index a7211d5af7ed..52cd288b805c 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -10720,8 +10720,10 @@ int64_t Client::_write(Fh *f, int64_t offset, uint64_t size, const char *buf, put_cap_ref(in, CEPH_CAP_AUTH_SHARED); r = __setattrx(in, &stx, CEPH_SETATTR_KILL_SGUID, f->actor_perms); - if (r < 0) + if (r < 0) { + put_cap_ref(in, CEPH_CAP_FILE_WR); return r; + } } else { put_cap_ref(in, CEPH_CAP_AUTH_SHARED); } -- 2.47.3