All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] __register_sysctl_table: do not drop subdir
@ 2020-05-27 10:48 Boris Sukholitko
  2020-05-27 12:58 ` Luis Chamberlain
  2020-06-03  1:07 ` [__register_sysctl_table] 4092a9304d: WARNING:at_fs/proc/proc_sysctl.c:#retire_sysctl_set kernel test robot
  0 siblings, 2 replies; 9+ messages in thread
From: Boris Sukholitko @ 2020-05-27 10:48 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: mcgrof, keescook, yzaikin

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@broadcom.com>
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


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-06-03  1:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-27 10:48 [PATCH] __register_sysctl_table: do not drop subdir Boris Sukholitko
2020-05-27 12:58 ` Luis Chamberlain
2020-05-28  8:08   ` Boris Sukholitko
2020-05-28 14:04     ` Eric W. Biederman
2020-05-28 14:20       ` Luis Chamberlain
2020-05-31 11:44         ` Boris Sukholitko
2020-06-01 13:17           ` Luis Chamberlain
2020-05-31 11:39       ` Boris Sukholitko
2020-06-03  1:07 ` [__register_sysctl_table] 4092a9304d: WARNING:at_fs/proc/proc_sysctl.c:#retire_sysctl_set kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.