NFS: Use common error handling code in nfs_sysfs_init()
Subsystems (3)
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.
Signed-off-by Markus Elfring <[email protected]>
--- fs/nfs/sysfs.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
fs/nfs/sysfs.c +8 -8
@@ -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