diff mbox series

ceph: fix memory leak on decode error in ceph_handle_caps

Message ID 20210702151440.93978-1-jlayton@kernel.org
State New
Headers show
Series ceph: fix memory leak on decode error in ceph_handle_caps | expand

Commit Message

Jeff Layton July 2, 2021, 3:14 p.m. UTC
If we hit a decoding error late in the frame, then we might exit the
function without putting the pool_ns string. Ensure that we always put
that reference on the way out of the function.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/ceph/caps.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 7bdefd0c789a..a7120fe23055 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -4129,8 +4129,9 @@  void ceph_handle_caps(struct ceph_mds_session *session,
 done:
 	mutex_unlock(&session->s_mutex);
 done_unlocked:
-	ceph_put_string(extra_info.pool_ns);
 	iput(inode);
+out:
+	ceph_put_string(extra_info.pool_ns);
 	return;
 
 flush_cap_releases:
@@ -4141,11 +4142,10 @@  void ceph_handle_caps(struct ceph_mds_session *session,
 	 */
 	ceph_flush_cap_releases(mdsc, session);
 	goto done;
-
 bad:
 	pr_err("ceph_handle_caps: corrupt message\n");
 	ceph_msg_dump(msg);
-	return;
+	goto out;
 }
 
 /*