lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220602055633.849545-1-dzm91@hust.edu.cn>
Date:   Thu,  2 Jun 2022 13:56:32 +0800
From:   Dongliang Mu <dzm91@...t.edu.cn>
To:     Chuck Lever <chuck.lever@...cle.com>
Cc:     Dongliang Mu <mudongliangabcd@...il.com>,
        linux-nfs@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] fs: nfsd: make destory function more elegant

From: Dongliang Mu <mudongliangabcd@...il.com>

In init_nfsd, the undo operation of create_proc_exports_entry is:

        remove_proc_entry("fs/nfs/exports", NULL);
        remove_proc_entry("fs/nfs", NULL);

This may lead to maintaince issue. Declare the undo function
destroy_proc_exports_entry based on CONFIG_PROC_FS

Signed-off-by: Dongliang Mu <mudongliangabcd@...il.com>
---
 fs/nfsd/nfsctl.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index 0621c2faf242..83b34ccbef5a 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -1450,11 +1450,21 @@ static int create_proc_exports_entry(void)
 	}
 	return 0;
 }
+
+static void destroy_proc_exports_entry(void)
+{
+	remove_proc_entry("fs/nfs/exports", NULL);
+	remove_proc_entry("fs/nfs", NULL);
+}
 #else /* CONFIG_PROC_FS */
 static int create_proc_exports_entry(void)
 {
 	return 0;
 }
+
+static void destroy_proc_exports_entry(void)
+{
+}
 #endif
 
 unsigned int nfsd_net_id;
@@ -1555,8 +1565,7 @@ static int __init init_nfsd(void)
 out_free_subsys:
 	unregister_pernet_subsys(&nfsd_net_ops);
 out_free_exports:
-	remove_proc_entry("fs/nfs/exports", NULL);
-	remove_proc_entry("fs/nfs", NULL);
+	destroy_proc_exports_entry();
 out_free_lockd:
 	nfsd_lockd_shutdown();
 	nfsd_drc_slab_free();
@@ -1576,8 +1585,7 @@ static void __exit exit_nfsd(void)
 	unregister_cld_notifier();
 	unregister_pernet_subsys(&nfsd_net_ops);
 	nfsd_drc_slab_free();
-	remove_proc_entry("fs/nfs/exports", NULL);
-	remove_proc_entry("fs/nfs", NULL);
+	destroy_proc_exports_entry();
 	nfsd_stat_shutdown();
 	nfsd_lockd_shutdown();
 	nfsd4_free_slabs();
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ