mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: WenTao Liang <vulab@iscas.ac.cn>
To: trondmy@kernel.org, anna@kernel.org
Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	WenTao Liang <vulab@iscas.ac.cn>,
	stable@vger.kernel.org
Subject: [PATCH] pnfs: fix refcount leak in pnfs_report_layoutstat()
Date: Thu, 11 Jun 2026 23:47:47 +0800	[thread overview]
Message-ID: <20260611154747.94154-1-vulab@iscas.ac.cn> (raw)

When pnfs_report_layoutstat() calls pnfs_get_layout_hdr() and passes
the reference through the inode field of the layoutstats data to
nfs42_proc_layoutstats_generic(), if rpc_run_task() in that function
fails (IS_ERR), nfs42_proc_layoutstats_generic() returns immediately
without releasing the reference.  This leaks the layout header
reference, leaks the allocated data, and leaves the
NFS_INO_LAYOUTSTATS flag stuck on the inode, preventing further
layoutstat reporting.

Fix by calling nfs42_layoutstat_release(data) before returning on
rpc_run_task() error, matching the existing error handling for a
missing inode.

Cc: stable@vger.kernel.org
Fixes: be3a5d233922 ("NFSv.2/pnfs Add a LAYOUTSTATS rpc function")
Signed-off-by: WenTao Liang <vulab@iscas.ac.cn>
---
 fs/nfs/nfs42proc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c
index 7602ede6f75f..7637ad894563 100644
--- a/fs/nfs/nfs42proc.c
+++ b/fs/nfs/nfs42proc.c
@@ -1076,8 +1076,10 @@ int nfs42_proc_layoutstats_generic(struct nfs_server *server,
 	nfs4_init_sequence(server->nfs_client, &data->args.seq_args,
 			   &data->res.seq_res, 0, 0);
 	task = rpc_run_task(&task_setup);
-	if (IS_ERR(task))
+	if (IS_ERR(task)) {
+		nfs42_layoutstat_release(data);
 		return PTR_ERR(task);
+	}
 	rpc_put_task(task);
 	return 0;
 }
-- 
2.50.1 (Apple Git-155)


             reply	other threads:[~2026-06-11 15:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-11 15:47 WenTao Liang [this message]
2026-06-11 17:36 ` Trond Myklebust

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=20260611154747.94154-1-vulab@iscas.ac.cn \
    --to=vulab@iscas.ac.cn \
    --cc=anna@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --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®