[PATCH] nfsd: Use common error handling code in svc_export_alloc()

Markus Elfring <Markus.Elfring-S0/[email protected]>
Newsgroups gmane.linux.nfs,gmane.linux.kernel,gmane.linux.kernel.janitors
Message-ID <[email protected]>
From: Markus Elfring <[email protected]>
Date: Thu, 11 Jun 2026 14:03:48 +0200

Use an additional label so that a bit of exception handling can be better
reused at the end of an if branch.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <[email protected]>
---
 fs/nfsd/export.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index eb020054f9a3..bb106733f3ec 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -1589,13 +1589,12 @@ static struct cache_head *svc_export_alloc(void)
 		return NULL;
 
 	i->ex_stats = kmalloc_obj(*(i->ex_stats));
-	if (!i->ex_stats) {
-		kfree(i);
-		return NULL;
-	}
+	if (!i->ex_stats)
+		goto free_export;
 
 	if (export_stats_init(i->ex_stats)) {
 		kfree(i->ex_stats);
+free_export:
 		kfree(i);
 		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.