From: Wentao Liang <vulab@iscas.ac.cn>
To: Dai.Ngo@oracle.com
Cc: anna@kernel.org, chuck.lever@oracle.com, jlayton@kernel.org,
linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org,
neil@brown.name, okorniev@redhat.com, tom@talpey.com,
trondmy@kernel.org, Wentao Liang <vulab@iscas.ac.cn>,
stable@vger.kernel.org
Subject: [PATCH] lockd: Fix host reference leak in nlmclnt_recovery()
Date: Wed, 16 Sep 2026 07:40:34 +0000 [thread overview]
Message-ID: <20260916074034.1972173-1-vulab@iscas.ac.cn> (raw)
In nlmclnt_recovery(), nlm_get_host(host) is called to take a reference
on the host before spawning the reclaimer thread via kthread_run(). If
kthread_run() fails, the reference is never released, and
host->h_reclaiming remains incremented, preventing subsequent reclaim
attempts.
Fix this by releasing the host reference with nlmclnt_release_host(host)
and resetting host->h_reclaiming to 0 on kthread_run() error.
Fixes: df94f000c46c ("lockd: convert reclaimer thread to kthread interface")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
fs/lockd/clntlock.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/fs/lockd/clntlock.c b/fs/lockd/clntlock.c
index 8fa30c42c92a..aba37847356c 100644
--- a/fs/lockd/clntlock.c
+++ b/fs/lockd/clntlock.c
@@ -216,10 +216,13 @@ nlmclnt_recovery(struct nlm_host *host)
if (!host->h_reclaiming++) {
nlm_get_host(host);
task = kthread_run(reclaimer, host, "%s-reclaim", host->h_name);
- if (IS_ERR(task))
+ if (IS_ERR(task)) {
printk(KERN_ERR "lockd: unable to spawn reclaimer "
"thread. Locks for %s won't be reclaimed! "
"(%ld)\n", host->h_name, PTR_ERR(task));
+ host->h_reclaiming = 0;
+ nlmclnt_release_host(host);
+ }
}
}
--
2.34.1
next reply other threads:[~2026-09-16 7:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 7:40 Wentao Liang [this message]
2026-09-16 11:07 ` Jeff Layton
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=20260916074034.1972173-1-vulab@iscas.ac.cn \
--to=vulab@iscas.ac.cn \
--cc=Dai.Ngo@oracle.com \
--cc=anna@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=jlayton@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neil@brown.name \
--cc=okorniev@redhat.com \
--cc=stable@vger.kernel.org \
--cc=tom@talpey.com \
--cc=trondmy@kernel.org \
/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
all inboxes | Powered by JetHome®