From: Hruday Rao <shreeramrahul94@gmail.com>
To: linux-nfs@vger.kernel.org
Cc: trondmy@kernel.org, anna@kernel.org,
linux-kernel@vger.kernel.org,
Rahul Rao <shreeramrahul94@gmail.com>
Subject: [PATCH] nfs: fix resource leak and warning in svc_destroy on callback init error
Date: Sun, 8 Nov 2026 14:48:46 +0530 [thread overview]
Message-ID: <20261108091846.114471-1-shreeramrahul94@gmail.com> (raw)
From: Rahul Rao <shreeramrahul94@gmail.com>
During NFSv4 callback initialization, if creating the PF_INET TCP
listener succeeds but the subsequent PF_INET6 listener creation fails
with an error other than -EAFNOSUPPORT, the function bails out without
cleaning up the previously created IPv4 transport.
This leaves serv->sv_permsocks non-empty when svc_destroy() is called
during error unwinding, triggering a svc_destroy warning.
Fix this by invoking svc_xprt_destroy_all(serv, net, true) to properly
tear down active transports upon initialization failure.
Signed-off-by: Rahul Rao <shreeramrahul94@gmail.com>
---
fs/nfs/callback.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
index bc282b744f34..3d2ad5297297 100644
--- a/fs/nfs/callback.c
+++ b/fs/nfs/callback.c
@@ -61,9 +61,11 @@ static int nfs4_callback_up_net(struct svc_serv *serv, struct net *net)
dprintk("NFS: Callback listener port = %u (af %u, net %x)\n",
nn->nfs_callback_tcpport6, PF_INET6, net->ns.inum);
} else if (ret != -EAFNOSUPPORT)
- goto out_err;
+ goto out_destroy_xprt;
return 0;
+out_destroy_xprt:
+ svc_xprt_destroy_all(serv, net, true);
out_err:
return (ret) ? ret : -ENOMEM;
}
--
2.43.0
reply other threads:[~2026-11-08 9:19 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261108091846.114471-1-shreeramrahul94@gmail.com \
--to=shreeramrahul94@gmail.com \
--cc=anna@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@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®