* [PATCH] nfs: fix resource leak and warning in svc_destroy on callback init error
@ 2026-11-08 9:18 Hruday Rao
0 siblings, 0 replies; only message in thread
From: Hruday Rao @ 2026-11-08 9:18 UTC (permalink / raw)
To: linux-nfs; +Cc: trondmy, anna, linux-kernel, Rahul Rao
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-08 9:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-08 9:18 [PATCH] nfs: fix resource leak and warning in svc_destroy on callback init error Hruday Rao
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®