From: Hangyu Hua <hbh25y@gmail.com>
To: ericvh@gmail.com, lucho@ionkov.net, asmadeus@codewreck.org,
linux_oss@crudebyte.com, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
tomasbortoli@gmail.com
Cc: v9fs-developer@lists.sourceforge.net, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, Hangyu Hua <hbh25y@gmail.com>
Subject: [PATCH] net: 9p: fix possible refcount leak in p9_read_work() and recv_done()
Date: Mon, 11 Jul 2022 14:59:07 +0800 [thread overview]
Message-ID: <20220711065907.23105-1-hbh25y@gmail.com> (raw)
A ref got in p9_tag_lookup needs to be put when functions enter the
error path.
Fix this by adding p9_req_put in error path.
Fixes: 728356dedeff ("9p: Add refcount to p9_req_t")
Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
---
net/9p/trans_fd.c | 3 +++
net/9p/trans_rdma.c | 1 +
2 files changed, 4 insertions(+)
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
index 8f8f95e39b03..c4ccb7b9e1bf 100644
--- a/net/9p/trans_fd.c
+++ b/net/9p/trans_fd.c
@@ -343,6 +343,7 @@ static void p9_read_work(struct work_struct *work)
p9_debug(P9_DEBUG_ERROR,
"No recv fcall for tag %d (req %p), disconnecting!\n",
m->rc.tag, m->rreq);
+ p9_req_put(m->rreq);
m->rreq = NULL;
err = -EIO;
goto error;
@@ -372,6 +373,8 @@ static void p9_read_work(struct work_struct *work)
"Request tag %d errored out while we were reading the reply\n",
m->rc.tag);
err = -EIO;
+ p9_req_put(m->rreq);
+ m->rreq = NULL;
goto error;
}
spin_unlock(&m->client->lock);
diff --git a/net/9p/trans_rdma.c b/net/9p/trans_rdma.c
index 88e563826674..82b5d6894ee2 100644
--- a/net/9p/trans_rdma.c
+++ b/net/9p/trans_rdma.c
@@ -317,6 +317,7 @@ recv_done(struct ib_cq *cq, struct ib_wc *wc)
/* Check that we have not yet received a reply for this request.
*/
if (unlikely(req->rc.sdata)) {
+ p9_req_put(req);
pr_err("Duplicate reply for request %d", tag);
goto err_out;
}
--
2.25.1
next reply other threads:[~2022-07-11 6:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-11 6:59 Hangyu Hua [this message]
2022-07-11 7:39 ` [PATCH] net: 9p: fix possible refcount leak in p9_read_work() and recv_done() asmadeus
2022-07-12 3:24 ` Hangyu Hua
2022-07-12 6:06 ` asmadeus
2022-07-12 8:31 ` Hangyu Hua
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220711065907.23105-1-hbh25y@gmail.com \
--to=hbh25y@gmail.com \
--cc=asmadeus@codewreck.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=ericvh@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux_oss@crudebyte.com \
--cc=lucho@ionkov.net \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=tomasbortoli@gmail.com \
--cc=v9fs-developer@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).