Skip to contentSkip to conversation

NFS: Use common error handling code in nfs_sysfs_init()

PATCH New Markus Elfring 1 participant 1 message Jun 11

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NFS: Use common error handling code in nfs_sysfs_init()

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.

---
 fs/nfs/sysfs.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
fs/nfs/sysfs.c +8 -8
index 3a197252a132..c4ccaa6fe87f 100644
@@ -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)
Signature · 1 line
2.54.0