diff mbox series

[v3,2/3] ceph: fix caps reference leakage for fscrypt size truncating

Message ID 20220412070745.22795-3-xiubli@redhat.com
State New
Headers show
Series ceph: misc fix size truncate for fscrypt | expand

Commit Message

Xiubo Li April 12, 2022, 7:07 a.m. UTC
Signed-off-by: Xiubo Li <xiubli@redhat.com>
---
 fs/ceph/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index a5145a2b7228..1c775a365b5e 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -2300,7 +2300,6 @@  static int fill_fscrypt_truncate(struct inode *inode,
 
 	pos = orig_pos;
 	ret = __ceph_sync_read(inode, &pos, &iter, &retry_op, &objver);
-	ceph_put_cap_refs(ci, got);
 	if (ret < 0)
 		goto out;
 
@@ -2364,6 +2363,7 @@  static int fill_fscrypt_truncate(struct inode *inode,
 out:
 	dout("%s %p size dropping cap refs on %s\n", __func__,
 	     inode, ceph_cap_string(got));
+	ceph_put_cap_refs(ci, got);
 	kunmap_local(iov.iov_base);
 	if (page)
 		__free_pages(page, 0);