[PATCH v2 1/2] NFS: Prevent resource leak in nfs_alloc_server()

Markus Elfring <[email protected]>
Newsgroups gmane.linux.kernel.janitors,gmane.linux.nfs,gmane.linux.kernel
Message-ID <[email protected]>
From: Markus Elfring <[email protected]>
Date: Sun, 14 Jun 2026 09:56:35 +0200

It was overlooked to call ida_free() after a failed nfs_alloc_iostats() call.
Thus add the missed function call in an if branch.

Fixes: 1c7251187dc067a6d460cf33ca67da9c1dd87807 ("NFS: add superblock sysfs entries")
Cc: [email protected]
Reported-by: Christophe Jaillet <[email protected]>
Closes: https://lore.kernel.org/linux-nfs/[email protected]/
Signed-off-by: Markus Elfring <[email protected]>
---
 fs/nfs/client.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 73b95318ba48..e15568e388f8 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -1088,6 +1088,7 @@ struct nfs_server *nfs_alloc_server(void)
 
 	server->io_stats = nfs_alloc_iostats();
 	if (!server->io_stats) {
+		ida_free(&s_sysfs_ids, server->s_sysfs_id);
 		kfree(server);
 		return NULL;
 	}
-- 
2.54.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.