Skip to contentSkip to conversation

ceph: fix memory leak on decode error in ceph_handle_caps

PATCH New Jeff Layton 1 participant 1 message Jul 2, 2021 Ceph client

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ceph: fix memory leak on decode error in ceph_handle_caps

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.

---
 fs/ceph/caps.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
fs/ceph/caps.c +3 -3
index 7bdefd0c789a..a7120fe23055 100644
@@ -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;
 }
 
 /*
Signature · 1 line
2.31.1