[PATCH] NFS: Use common error handling code in nfs_sysfs_init()

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 13:40:30 +0200

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 <[email protected]>
---
 fs/nfs/sysfs.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/fs/nfs/sysfs.c b/fs/nfs/sysfs.c
index 3a197252a132..c4ccaa6fe87f 100644
--- a/fs/nfs/sysfs.c
+++ b/fs/nfs/sysfs.c
@@ -49,22 +49,22 @@ int nfs_sysfs_init(void)
 		return -ENOMEM;
 
 	ret = kobject_set_name(&nfs_kset->kobj, "nfs");
-	if (ret) {
-		kfree(nfs_kset);
-		return ret;
-	}
+	if (ret)
+		goto free_kset;
 
 	nfs_kset->kobj.parent = fs_kobj;
 	nfs_kset->kobj.ktype = &nfs_kset_type;
 	nfs_kset->kobj.kset = NULL;
 
 	ret = kset_register(nfs_kset);
-	if (ret) {
-		kfree(nfs_kset);
-		return ret;
-	}
+	if (ret)
+		goto free_kset;
 
 	return 0;
+
+free_kset:
+	kfree(nfs_kset);
+	return ret;
 }
 
 void nfs_sysfs_exit(void)
-- 
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.