]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: fix CEPH_CAP_FILE_WR caps reference leakage in _write()
authorXiubo Li <xiubli@redhat.com>
Tue, 14 Feb 2023 11:35:14 +0000 (19:35 +0800)
committerXiubo Li <xiubli@redhat.com>
Tue, 11 Apr 2023 02:01:14 +0000 (10:01 +0800)
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 <xiubli@redhat.com>
(cherry picked from commit 93d69dd77f10b901cd0c7b713bf71acb365e5271)

src/client/Client.cc

index e1c1de294831eb451de10acc2ad7a937af109e75..4d74058b9d8b923f4e4001cba8c3d6281d0c52b2 100644 (file)
@@ -10729,8 +10729,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);
   }