From: Markus Elfring Date: Sun, 14 Jun 2026 08:06:11 +0000 (+0200) Subject: NFS: Use common error handling code in nfs_alloc_server() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=284ea3fb4f6715201e1d9ef3474c25e817ad70e9;p=thirdparty%2Flinux.git NFS: Use common error handling code in nfs_alloc_server() Use an additional label so that a bit of exception handling can be better reused at the end of this function implementation. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Anna Schumaker --- diff --git a/fs/nfs/client.c b/fs/nfs/client.c index 0781b15e7e05c..48ce013b30b07 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c @@ -1049,10 +1049,8 @@ struct nfs_server *nfs_alloc_server(void) return NULL; server->s_sysfs_id = ida_alloc(&s_sysfs_ids, GFP_KERNEL); - if (server->s_sysfs_id < 0) { - kfree(server); - return NULL; - } + if (server->s_sysfs_id < 0) + goto free_server; server->client = server->client_acl = ERR_PTR(-EINVAL); @@ -1075,8 +1073,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; + goto free_server; } server->change_attr_type = NFS4_CHANGE_TYPE_IS_UNDEFINED; @@ -1090,6 +1087,10 @@ struct nfs_server *nfs_alloc_server(void) rpc_init_wait_queue(&server->uoc_rpcwaitq, "NFS UOC"); return server; + +free_server: + kfree(server); + return NULL; } EXPORT_SYMBOL_GPL(nfs_alloc_server);