* [PATCH] NFS: Use common error handling code in nfs_sysfs_init()
@ 2026-06-11 11:45 Markus Elfring
0 siblings, 0 replies; only message in thread
From: Markus Elfring @ 2026-06-11 11:45 UTC (permalink / raw)
To: linux-nfs, Anna Schumaker, Trond Myklebust
Cc: LKML, kernel-janitors, Christian Brauner, Christoph Hellwig, Chuck Lever
From: Markus Elfring <elfring@users.sourceforge.net>
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 <elfring@users.sourceforge.net>
---
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-06-11 11:45 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-11 11:45 [PATCH] NFS: Use common error handling code in nfs_sysfs_init() Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®