From: Boris Sukholitko <boris.sukholitko@broadcom.com>
To: linux-fsdevel@vger.kernel.org
Cc: mcgrof@kernel.org, keescook@chromium.org, yzaikin@google.com
Subject: [PATCH] __register_sysctl_table: do not drop subdir
Date: Wed, 27 May 2020 13:48:48 +0300 [thread overview]
Message-ID: <20200527104848.GA7914@nixbox> (raw)
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
next reply other threads:[~2020-05-27 10:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-27 10:48 Boris Sukholitko [this message]
2020-05-27 12:58 ` [PATCH] __register_sysctl_table: do not drop subdir 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200527104848.GA7914@nixbox \
--to=boris.sukholitko@broadcom.com \
--cc=keescook@chromium.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=yzaikin@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).