Message ID | 20241002200805.34376-1-batrick@batbytes.com |
---|---|
State | New |
Headers | show |
Series | ceph: fix cap ref leak via netfs init_request | expand |
Ilya Dryomov <idryomov@gmail.com> wrote: > The actual problem is that netfs_alloc_request() just frees rreq if > init_request() callout fails and ceph_netfs_free_request() is never > called, right? I could make it call ->free_request() in the case that ->init_request() returns an error, though I'd prefer that the cleanup be done in ->init_request() rather than passing a partially set-up state to ->free_request(). David
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index 53fef258c2bc..702c6a730b70 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -489,8 +489,11 @@ static int ceph_init_request(struct netfs_io_request *rreq, struct file *file) rreq->io_streams[0].sreq_max_len = fsc->mount_options->rsize; out: - if (ret < 0) + if (ret < 0) { + if (got) + ceph_put_cap_refs(ceph_inode(inode), got); kfree(priv); + } return ret; }