[PATCH] __register_sysctl_table: do not drop subdir

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Successful get_subdir returns dir with its header.nreg properly
adjusted. No need to drop the dir in that case.

Signed-off-by: Boris Sukholitko <boris.sukholitko@xxxxxxxxxxxx>
Fixes: 7ec66d06362d (sysctl: Stop requiring explicit management of sysctl directories)
---
 fs/proc/proc_sysctl.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index b6f5d459b087..6f237f0eb531 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -1286,8 +1286,8 @@ struct ctl_table_header *__register_sysctl_table(
 {
 	struct ctl_table_root *root = set->dir.header.root;
 	struct ctl_table_header *header;
+	struct ctl_dir *dir, *start_dir;
 	const char *name, *nextname;
-	struct ctl_dir *dir;
 	struct ctl_table *entry;
 	struct ctl_node *node;
 	int nr_entries = 0;
@@ -1307,6 +1307,7 @@ struct ctl_table_header *__register_sysctl_table(
 
 	spin_lock(&sysctl_lock);
 	dir = &set->dir;
+	start_dir = dir;
 	/* Reference moved down the diretory tree get_subdir */
 	dir->header.nreg++;
 	spin_unlock(&sysctl_lock);
@@ -1333,7 +1334,8 @@ struct ctl_table_header *__register_sysctl_table(
 	if (insert_header(dir, header))
 		goto fail_put_dir_locked;
 
-	drop_sysctl_table(&dir->header);
+	if (start_dir == dir)
+		drop_sysctl_table(&dir->header);
 	spin_unlock(&sysctl_lock);
 
 	return header;
-- 
2.23.1




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux